24#ifndef PXR_USD_PCP_ITERATOR_H
25#define PXR_USD_PCP_ITERATOR_H
28#include "pxr/usd/pcp/api.h"
29#include "pxr/usd/pcp/node.h"
33#include "pxr/usd/sdf/site.h"
39PXR_NAMESPACE_OPEN_SCOPE
42class PcpPrimIndex_Graph;
57 explicit _PtrProxy(
const PcpNodeRef& nodeRef) : _nodeRef(nodeRef) {}
61 using iterator_category = std::random_access_iterator_tag;
64 using pointer = _PtrProxy;
65 using difference_type = std::ptrdiff_t;
71 Pcp_CompressedSdSite GetCompressedSdSite(
size_t layerIndex)
const
73 return Pcp_CompressedSdSite(_nodeIdx, layerIndex);
76 reference operator*()
const {
return dereference(); }
77 pointer operator->()
const {
return pointer(dereference()); }
78 reference operator[](
const difference_type index)
const {
80 advanced.advance(index);
81 return advanced.dereference();
85 return -distance_to(other);
112 result.advance(increment);
118 result.advance(-decrement);
137 return !equal(other);
142 return _nodeIdx < other._nodeIdx;
147 return _nodeIdx <= other._nodeIdx;
152 return _nodeIdx > other._nodeIdx;
157 return _nodeIdx >= other._nodeIdx;
163 _graph(graph), _nodeIdx(nodeIdx) {}
165 void increment() { ++_nodeIdx; }
166 void decrement() { --_nodeIdx; }
167 void advance(difference_type n) { _nodeIdx += n; }
169 return (difference_type)(other._nodeIdx) - _nodeIdx;
172 return (_graph == other._graph) & (_nodeIdx == other._nodeIdx);
174 reference dereference()
const {
179 PcpPrimIndex_Graph* _graph =
nullptr;
189 :
public Tf_ProxyReferenceReverseIterator<PcpNodeIterator>
194 : Tf_ProxyReferenceReverseIterator<PcpNodeIterator>(iter) {}
206 SdfSite* operator->() {
return &_site; }
209 explicit _PtrProxy(
const SdfSite& site) : _site(site) {}
213 using iterator_category = std::random_access_iterator_tag;
216 using pointer = _PtrProxy;
217 using difference_type = std::ptrdiff_t;
235 Pcp_SdSiteRef _GetSiteRef()
const;
237 reference operator*()
const {
return dereference(); }
238 pointer operator->()
const {
return pointer(dereference()); }
239 reference operator[](
const difference_type index)
const {
241 advanced.advance(index);
242 return advanced.dereference();
246 return -distance_to(other);
273 result.advance(increment);
279 result.advance(-decrement);
298 return !equal(other);
303 return _pos < other._pos;
308 return _pos <= other._pos;
313 return _pos > other._pos;
318 return _pos >= other._pos;
327 void advance(difference_type n);
333 reference dereference()
const;
346 :
public Tf_ProxyReferenceReverseIterator<PcpPrimIterator>
351 : Tf_ProxyReferenceReverseIterator<PcpPrimIterator>(iter) { }
356 return (--tmp).GetNode();
359 Pcp_SdSiteRef _GetSiteRef()
const
362 return (--tmp)._GetSiteRef();
374 using iterator_category = std::random_access_iterator_tag;
375 using value_type =
const SdfPropertySpecHandle;
376 using reference =
const SdfPropertySpecHandle&;
377 using pointer =
const SdfPropertySpecHandle*;
378 using difference_type = std::ptrdiff_t;
398 reference operator*()
const {
return dereference(); }
399 pointer operator->()
const {
return &(dereference()); }
400 reference operator[](
const difference_type index)
const {
402 advanced.advance(index);
403 return advanced.dereference();
407 return -distance_to(other);
434 result.advance(increment);
440 result.advance(-decrement);
459 return !equal(other);
464 return _pos < other._pos;
469 return _pos <= other._pos;
474 return _pos > other._pos;
479 return _pos >= other._pos;
488 void advance(difference_type n);
494 reference dereference()
const;
507 :
public std::reverse_iterator<PcpPropertyIterator>
512 : std::reverse_iterator<PcpPropertyIterator>(iter) { }
517 return (--tmp).GetNode();
523 return (--tmp).IsLocal();
530#define PCP_DEFINE_RANGE(Range, Iterator, ReverseIterator) \
531 typedef std::pair<Iterator, Iterator> Range; \
533 inline Iterator begin(Range &range) { return range.first; } \
534 inline Iterator begin(const Range &range) { return range.first; } \
535 inline Iterator end(Range &range) { return range.second; } \
536 inline Iterator end(const Range &range) { return range.second; } \
539 struct Tf_IteratorInterface<Range, false> { \
540 typedef Iterator IteratorType; \
541 static IteratorType Begin(Range &c) { return c.first; } \
542 static IteratorType End(Range &c) { return c.second; } \
546 struct Tf_IteratorInterface<const Range, false> { \
547 typedef Iterator IteratorType; \
548 static IteratorType Begin(Range const &c) { return c.first; } \
549 static IteratorType End(Range const &c) { return c.second; } \
553 struct Tf_IteratorInterface<Range, true> { \
554 typedef ReverseIterator IteratorType; \
555 static IteratorType Begin(Range &c) \
556 { return IteratorType(c.second); } \
557 static IteratorType End(Range &c) \
558 { return IteratorType(c.first); } \
562 struct Tf_IteratorInterface<const Range, true> { \
563 typedef ReverseIterator IteratorType; \
564 static IteratorType Begin(Range const &c) \
565 { return IteratorType(c.second); } \
566 static IteratorType End(Range const &c) \
567 { return IteratorType(c.first); } \
571 struct Tf_ShouldIterateOverCopy<Range> : std::true_type {}; \
574 struct Tf_ShouldIterateOverCopy<const Range> : std::true_type {}
591 typedef PcpNodeRange RangeType;
598 typedef PcpPrimRange RangeType;
605 typedef PcpPropertyRange RangeType;
609PXR_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.