Loading...
Searching...
No Matches
sceneIndexPrimView.h
1//
2// Copyright 2022 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_IMAGING_HD_SCENE_INDEX_PRIM_VIEW_H
8#define PXR_IMAGING_HD_SCENE_INDEX_PRIM_VIEW_H
9
10#include "pxr/pxr.h"
11
12#include "pxr/imaging/hd/api.h"
13
14#include "pxr/usd/sdf/path.h"
16
17PXR_NAMESPACE_OPEN_SCOPE
18
20
56{
57public:
58 enum Order
59 {
60 ChildPrimPaths,
61 Lexicographic
62 };
63
64 class const_iterator
65 {
66 public:
67 inline const SdfPath &operator*() const;
68 inline const SdfPath *operator->() const;
69
70 HD_API
71 const_iterator& operator++();
72
73 inline void SkipDescendants();
74 inline bool operator==(const const_iterator &other) const;
75 inline bool operator!=(const const_iterator &other) const;
76
77 private:
78 friend class HdSceneIndexPrimView;
79 struct _StackFrame;
80
81 const_iterator(HdSceneIndexBaseRefPtr const &inputSceneIndex,
82 const SdfPath &root,
83 Order order);
84 const_iterator(HdSceneIndexBaseRefPtr const &inputSceneIndex,
85 Order order);
86
87 HdSceneIndexBaseRefPtr const _inputSceneIndex;
88 std::vector<_StackFrame> _stack;
89 bool _skipDescendants;
90 Order _order;
91 };
92
93 HD_API
94 HdSceneIndexPrimView(HdSceneIndexBaseRefPtr const &inputSceneIndex,
95 Order order = ChildPrimPaths);
96
97 HD_API
98 HdSceneIndexPrimView(HdSceneIndexBaseRefPtr const &inputSceneIndex,
99 const SdfPath &root,
100 Order order = ChildPrimPaths);
101
102 HD_API
103 const const_iterator &begin() const;
104
105 HD_API
106 const const_iterator &end() const;
107
108private:
109 const const_iterator _begin;
110 const const_iterator _end;
111};
112
113struct
114HdSceneIndexPrimView::const_iterator::_StackFrame
115{
116 std::vector<SdfPath> paths;
117 size_t index;
118
119 bool operator==(const _StackFrame &other) const {
120 return paths == other.paths && index == other.index;
121 }
122};
123
124const SdfPath &
125HdSceneIndexPrimView::const_iterator::operator*() const
126{
127 const _StackFrame &frame = _stack.back();
128 return frame.paths[frame.index];
129}
130
131const SdfPath *
132HdSceneIndexPrimView::const_iterator::operator->() const
133{
134 return &(**this);
135}
136
137void
138HdSceneIndexPrimView::const_iterator::SkipDescendants()
139{
140 _skipDescendants = true;
141}
142
143bool
144HdSceneIndexPrimView::const_iterator::operator==(
145 const const_iterator &other) const
146{
147 return _stack == other._stack;
148}
149
150bool
151HdSceneIndexPrimView::const_iterator::operator!=(
152 const const_iterator &other) const
153{
154 return !(*this == other);
155}
156
157PXR_NAMESPACE_CLOSE_SCOPE
158
159#endif
Abstract interface to scene data.
Definition sceneIndex.h:55
A range to iterate over all descendants of a given prim (including the prim itself) in a scene index ...
A path value used to locate objects in layers or scenegraphs.
Definition path.h:281
Standard pointer typedefs.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition declarePtrs.h:58