24 #ifndef PXR_USD_PCP_NODE_H 25 #define PXR_USD_PCP_NODE_H 28 #include "pxr/usd/pcp/api.h" 32 #include "pxr/base/tf/hashset.h" 34 #include <boost/operators.hpp> 35 #include <boost/iterator/iterator_facade.hpp> 36 #include <boost/iterator/reverse_iterator.hpp> 38 PXR_NAMESPACE_OPEN_SCOPE
44 class PcpNodeRef_ChildrenIterator;
45 class PcpNodeRef_ChildrenReverseIterator;
47 typedef std::shared_ptr<PcpErrorBase> PcpErrorBasePtr;
68 public boost::totally_ordered<PcpNodeRef>
71 typedef PcpNodeRef_ChildrenIterator child_const_iterator;
72 typedef PcpNodeRef_ChildrenReverseIterator child_const_reverse_iterator;
73 typedef std::pair<child_const_iterator,
74 child_const_iterator> child_const_range;
89 return _nodeIdx == rhs._nodeIdx && _graph == rhs._graph;
100 size_t operator()(
const PcpNodeRef& rhs)
const 138 PcpErrorBasePtr *error);
144 const PcpPrimIndex_GraphRefPtr& subgraph,
const PcpArc& arc,
145 PcpErrorBasePtr *error);
230 bool IsDueToAncestor()
const;
237 bool HasSymmetry()
const;
253 bool IsInert()
const;
261 bool IsCulled()
const;
268 bool IsRestricted()
const;
280 bool HasSpecs()
const;
285 Pcp_CompressedSdSite GetCompressedSdSite(
size_t layerIndex)
const 287 return Pcp_CompressedSdSite(_nodeIdx, layerIndex);
291 friend class PcpPrimIndex_Graph;
293 friend class PcpNodeRef_ChildrenIterator;
294 friend class PcpNodeRef_ChildrenReverseIterator;
295 friend class PcpNodeRef_PrivateChildrenConstIterator;
296 friend class PcpNodeRef_PrivateChildrenConstReverseIterator;
299 PcpNodeRef(PcpPrimIndex_Graph* graph,
size_t idx)
300 : _graph(graph), _nodeIdx(idx)
303 size_t _GetNodeIndex()
const {
return _nodeIdx; }
305 inline size_t _GetParentIndex()
const;
306 inline size_t _GetOriginIndex()
const;
309 PcpPrimIndex_Graph* _graph;
321 typedef TfHashSet<PcpNodeRef, PcpNodeRef::Hash> PcpNodeRefHashSet;
322 typedef std::vector<PcpNodeRef> PcpNodeRefVector;
329 class PcpNodeRef_ChildrenIterator
330 :
public boost::iterator_facade<
331 PcpNodeRef_ChildrenIterator,
333 boost::forward_traversal_tag,
340 PcpNodeRef_ChildrenIterator();
345 PcpNodeRef_ChildrenIterator(
const PcpNodeRef& node,
bool end =
false);
348 friend class boost::iterator_core_access;
351 bool equal(
const PcpNodeRef_ChildrenIterator& other)
const 355 return (_node == other._node && _index == other._index);
357 reference dereference()
const 359 return reference(_node._graph, _index);
369 friend class PcpNodeRef_ChildrenReverseIterator;
377 class PcpNodeRef_ChildrenReverseIterator
378 :
public boost::iterator_facade<
379 PcpNodeRef_ChildrenReverseIterator,
381 boost::forward_traversal_tag,
388 PcpNodeRef_ChildrenReverseIterator();
392 PcpNodeRef_ChildrenReverseIterator(
const PcpNodeRef_ChildrenIterator&);
397 PcpNodeRef_ChildrenReverseIterator(
const PcpNodeRef& node,
bool end =
false);
400 friend class boost::iterator_core_access;
403 bool equal(
const PcpNodeRef_ChildrenReverseIterator& other)
const 407 return (_node == other._node && _index == other._index);
409 reference dereference()
const 411 return reference(_node._graph, _index);
423 struct Tf_IteratorInterface<
PcpNodeRef::child_const_range, false> {
424 typedef PcpNodeRef::child_const_iterator IteratorType;
425 static IteratorType Begin(PcpNodeRef::child_const_range
const &c)
429 static IteratorType End(PcpNodeRef::child_const_range
const &c)
436 struct Tf_IteratorInterface<
PcpNodeRef::child_const_range, true> {
437 typedef PcpNodeRef::child_const_reverse_iterator IteratorType;
438 static IteratorType Begin(PcpNodeRef::child_const_range
const &c)
442 static IteratorType End(PcpNodeRef::child_const_range
const &c)
449 struct Tf_ShouldIterateOverCopy<
PcpNodeRef::child_const_range> :
454 PcpNodeRef_ChildrenIterator
455 begin(
const PcpNodeRef::child_const_range& r)
462 PcpNodeRef_ChildrenIterator
463 end(
const PcpNodeRef::child_const_range& r)
471 int PcpNode_GetNonVariantPathElementCount(
const SdfPath &path);
473 PXR_NAMESPACE_CLOSE_SCOPE
475 #endif // PXR_USD_PCP_NODE_H Represents an arc connecting two nodes in the prim index.
An expression that yields a PcpMapFunction value.
PCP_API bool CanContributeSpecs() const
Returns true if this node is allowed to contribute opinions for composition, false otherwise.
PCP_API const PcpMapExpression & GetMapToParent() const
Returns mapping function used to translate paths and values from this node to its parent node.
PCP_API const PcpMapExpression & GetMapToRoot() const
Returns mapping function used to translate paths and values from this node directly to the root node.
size_t PcpNodeRef::* UnspecifiedBoolType
Returns true if this is a valid node reference, false otherwise.
A site specifies a path in a layer stack of scene description.
PCP_API int GetNamespaceDepth() const
Returns the absolute namespace depth of the node that introduced this node.
A simple iterator adapter for STL containers.
PCP_API PcpNodeRef GetRootNode() const
Walk up to the root node of this expression.
PcpNode represents a node in an expression tree for compositing scene description.
PCP_API PcpNodeRef InsertChildSubgraph(const PcpPrimIndex_GraphRefPtr &subgraph, const PcpArc &arc, PcpErrorBasePtr *error)
Inserts subgraph as a child of this node, with the root node of subtree connected to this node via ar...
PCP_API void SetRestricted(bool restricted)
Get/set whether this node is restricted.
PCP_API const PcpLayerStackRefPtr & GetLayerStack() const
Returns the layer stack for the site this node represents.
PCP_API PcpNodeRef GetOriginNode() const
Returns the immediate origin node for this node.
PCP_API int GetSiblingNumAtOrigin() const
Returns this node's index among siblings with the same arc type at this node's origin.
PCP_API const SdfPath & GetPath() const
Returns the path for the site this node represents.
PCP_API bool IsRootNode() const
Returns true if this node is the root node of the prim index graph.
PCP_API PcpNodeRef GetParentNode() const
Returns this node's immediate parent node.
PCP_API bool operator<(const PcpNodeRef &rhs) const
Returns true if this node is 'less' than rhs.
PCP_API int GetDepthBelowIntroduction() const
Return the number of levels of namespace this node's site is below the level at which it was introduc...
PCP_API SdfPath GetPathAtIntroduction() const
Returns the path for this node's site when it was introduced.
Object used to iterate over nodes in the prim index graph in strong-to-weak order.
PcpPrimIndex_Graph * GetOwningGraph() const
Returns the graph that this node belongs to.
bool operator==(const PcpNodeRef &rhs) const
Returns true if this references the same node as rhs.
PCP_API child_const_range GetChildrenRange() const
Returns an iterator range over the children nodes in strongest to weakest order.
PCP_API PcpNodeRef GetOriginRootNode() const
Walk up to the root origin node for this node.
A path value used to locate objects in layers or scenegraphs.
PCP_API void SetCulled(bool culled)
Get/set whether this node is culled.
constexpr size_t PCP_INVALID_INDEX
A value which indicates an invalid index.
PCP_API void SetPermission(SdfPermission perm)
Get/set the permission for this node.
PCP_API PcpArcType GetArcType() const
Returns the type of arc connecting this node to its parent node.
PCP_API void * GetUniqueIdentifier() const
Returns a value that uniquely identifies this node.
PCP_API PcpLayerStackSite GetSite() const
Get the site this node represents.
size_t hash_value(const half h)
Overload hash_value for half.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
PCP_API void SetIsDueToAncestor(bool isDueToAncestor)
Get/set whether this node was introduced by being copied from its namespace ancestor,...
PCP_API void SetInert(bool inert)
Get/set whether this node is inert.
PCP_API PcpNodeRef InsertChild(const PcpLayerStackSite &site, const PcpArc &arc, PcpErrorBasePtr *error)
Inserts a new child node for site, connected to this node via arc.
PCP_API SdfPath GetIntroPath() const
Get the path that introduced this node.
PCP_API void SetHasSymmetry(bool hasSymmetry)
Get/set whether this node provides any symmetry opinions, either directly or from a namespace ancesto...
PCP_API void SetHasSpecs(bool hasSpecs)
Returns true if this node has opinions authored for composition, false otherwise.
SdfPermission
An enum that defines permission levels.
Base class for all error types.
PcpArcType
Describes the type of arc connecting two nodes in the prim index.