7#ifndef PXR_USD_PCP_ITERATOR_H
8#define PXR_USD_PCP_ITERATOR_H
11#include "pxr/usd/pcp/api.h"
12#include "pxr/usd/pcp/node.h"
16#include "pxr/usd/sdf/site.h"
22PXR_NAMESPACE_OPEN_SCOPE
25class PcpPrimIndex_Graph;
40 explicit _PtrProxy(
const PcpNodeRef& nodeRef) : _nodeRef(nodeRef) {}
44 using iterator_category = std::random_access_iterator_tag;
47 using pointer = _PtrProxy;
48 using difference_type = std::ptrdiff_t;
54 Pcp_CompressedSdSite GetCompressedSdSite(
size_t layerIndex)
const
56 return Pcp_CompressedSdSite(_nodeIdx, layerIndex);
67 reference operator*()
const {
return dereference(); }
68 pointer operator->()
const {
return pointer(dereference()); }
69 reference operator[](
const difference_type index)
const {
71 advanced.advance(index);
72 return advanced.dereference();
76 return -distance_to(other);
103 result.advance(increment);
109 result.advance(-decrement);
128 return !equal(other);
133 return _nodeIdx < other._nodeIdx;
138 return _nodeIdx <= other._nodeIdx;
143 return _nodeIdx > other._nodeIdx;
148 return _nodeIdx >= other._nodeIdx;
154 _graph(graph), _nodeIdx(nodeIdx) {}
156 void increment() { ++_nodeIdx; }
157 void decrement() { --_nodeIdx; }
158 void advance(difference_type n) { _nodeIdx += n; }
160 return (difference_type)(other._nodeIdx) - _nodeIdx;
163 return (_graph == other._graph) & (_nodeIdx == other._nodeIdx);
165 reference dereference()
const {
170 PcpPrimIndex_Graph* _graph =
nullptr;
180 :
public Tf_ProxyReferenceReverseIterator<PcpNodeIterator>
185 : Tf_ProxyReferenceReverseIterator<PcpNodeIterator>(iter) {}
197 SdfSite* operator->() {
return &_site; }
200 explicit _PtrProxy(
const SdfSite& site) : _site(site) {}
204 using iterator_category = std::random_access_iterator_tag;
207 using pointer = _PtrProxy;
208 using difference_type = std::ptrdiff_t;
226 Pcp_SdSiteRef _GetSiteRef()
const;
228 reference operator*()
const {
return dereference(); }
229 pointer operator->()
const {
return pointer(dereference()); }
230 reference operator[](
const difference_type index)
const {
232 advanced.advance(index);
233 return advanced.dereference();
237 return -distance_to(other);
264 result.advance(increment);
270 result.advance(-decrement);
289 return !equal(other);
294 return _pos < other._pos;
299 return _pos <= other._pos;
304 return _pos > other._pos;
309 return _pos >= other._pos;
318 void advance(difference_type n);
324 reference dereference()
const;
337 :
public Tf_ProxyReferenceReverseIterator<PcpPrimIterator>
342 : Tf_ProxyReferenceReverseIterator<PcpPrimIterator>(iter) { }
347 return (--tmp).GetNode();
350 Pcp_SdSiteRef _GetSiteRef()
const
353 return (--tmp)._GetSiteRef();
365 using iterator_category = std::random_access_iterator_tag;
366 using value_type =
const SdfPropertySpecHandle;
367 using reference =
const SdfPropertySpecHandle&;
368 using pointer =
const SdfPropertySpecHandle*;
369 using difference_type = std::ptrdiff_t;
389 reference operator*()
const {
return dereference(); }
390 pointer operator->()
const {
return &(dereference()); }
391 reference operator[](
const difference_type index)
const {
393 advanced.advance(index);
394 return advanced.dereference();
398 return -distance_to(other);
425 result.advance(increment);
431 result.advance(-decrement);
450 return !equal(other);
455 return _pos < other._pos;
460 return _pos <= other._pos;
465 return _pos > other._pos;
470 return _pos >= other._pos;
479 void advance(difference_type n);
485 reference dereference()
const;
498 :
public std::reverse_iterator<PcpPropertyIterator>
503 : std::reverse_iterator<PcpPropertyIterator>(iter) { }
508 return (--tmp).GetNode();
514 return (--tmp).IsLocal();
521#define PCP_DEFINE_RANGE(Range, Iterator, ReverseIterator) \
522 typedef std::pair<Iterator, Iterator> Range; \
524 inline Iterator begin(Range &range) { return range.first; } \
525 inline Iterator begin(const Range &range) { return range.first; } \
526 inline Iterator end(Range &range) { return range.second; } \
527 inline Iterator end(const Range &range) { return range.second; } \
530 struct Tf_IteratorInterface<Range, false> { \
531 typedef Iterator IteratorType; \
532 static IteratorType Begin(Range &c) { return c.first; } \
533 static IteratorType End(Range &c) { return c.second; } \
537 struct Tf_IteratorInterface<const Range, false> { \
538 typedef Iterator IteratorType; \
539 static IteratorType Begin(Range const &c) { return c.first; } \
540 static IteratorType End(Range const &c) { return c.second; } \
544 struct Tf_IteratorInterface<Range, true> { \
545 typedef ReverseIterator IteratorType; \
546 static IteratorType Begin(Range &c) \
547 { return IteratorType(c.second); } \
548 static IteratorType End(Range &c) \
549 { return IteratorType(c.first); } \
553 struct Tf_IteratorInterface<const Range, true> { \
554 typedef ReverseIterator IteratorType; \
555 static IteratorType Begin(Range const &c) \
556 { return IteratorType(c.second); } \
557 static IteratorType End(Range const &c) \
558 { return IteratorType(c.first); } \
562 struct Tf_ShouldIterateOverCopy<Range> : std::true_type {}; \
565 struct Tf_ShouldIterateOverCopy<const Range> : std::true_type {}
582 typedef PcpNodeRange RangeType;
589 typedef PcpPrimRange RangeType;
596 typedef PcpPropertyRange RangeType;
600PXR_NAMESPACE_CLOSE_SCOPE
A simple iterator adapter for STL containers.
Object used to iterate over nodes in the prim index graph in strong-to-weak order.
PcpNodeIterator()=default
Constructs an invalid iterator.
PcpNode represents a node in an expression tree for compositing scene description.
Object used to iterate over nodes in the prim index graph in weak-to-strong order.
PcpPrimIndex is an index of the all sites of scene description that contribute opinions to a specific...
Object used to iterate over prim specs in the prim index graph in strong-to-weak order.
PCP_API PcpPrimIterator()
Constructs an invalid iterator.
PCP_API PcpPrimIterator(const PcpPrimIndex *primIndex, size_t pos)
Constructs a prim iterator beginning at position pos in the prim stack of prim index primIndex.
PCP_API PcpNodeRef GetNode() const
Returns the PcpNode from which the current prim originated.
Object used to iterate over prim specs in the prim index graph in weak-to-strong order.
PcpPropertyIndex is an index of all sites in scene description that contribute opinions to a specific...
Object used to iterate over property specs in a property index in strong-to-weak order.
PCP_API PcpPropertyIterator(const PcpPropertyIndex &index, size_t pos=0)
Constructs a property iterator for index beginning at position pos in the property stack.
PCP_API PcpPropertyIterator()
Constructs an invalid iterator.
PCP_API bool IsLocal() const
Returns true if the current property is local to the owning property index's layer stack,...
PCP_API PcpNodeRef GetNode() const
Returns the PcpNode from which the current property originated.
Object used to iterate over property specs in a property index in weak-to-strong order.
An SdfSite is a simple representation of a location in a layer where opinions may possibly be found.
#define TF_DEV_AXIOM(cond)
The same as TF_AXIOM, but compiled only in dev builds.
Traits class for retrieving useful characteristics about one of the Pcp iterator types above.
constexpr size_t PCP_INVALID_INDEX
A value which indicates an invalid index.