This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
48{
49public:
50 class const_iterator
51 {
52 public:
53 inline const SdfPath &operator*() const;
54
55 HD_API
56 const_iterator& operator++();
57
58 inline void SkipDescendants();
59 inline bool operator==(const const_iterator &other) const;
60 inline bool operator!=(const const_iterator &other) const;
61
62 private:
63 friend class HdSceneIndexPrimView;
64 struct _StackFrame;
65
66 const_iterator(HdSceneIndexBaseRefPtr const &inputSceneIndex,
67 const SdfPath &root);
68 const_iterator(HdSceneIndexBaseRefPtr const &inputSceneIndex);
69
70 HdSceneIndexBaseRefPtr const _inputSceneIndex;
71 std::vector<_StackFrame> _stack;
72 bool _skipDescendants;
73 };
74
75 HD_API
76 HdSceneIndexPrimView(HdSceneIndexBaseRefPtr const &inputSceneIndex);
77
78 HD_API
79 HdSceneIndexPrimView(HdSceneIndexBaseRefPtr const &inputSceneIndex,
80 const SdfPath &root);
81
82 HD_API
83 const const_iterator &begin() const;
84
85 HD_API
86 const const_iterator &end() const;
87
88private:
89 const const_iterator _begin;
90 const const_iterator _end;
91};
92
93struct
94HdSceneIndexPrimView::const_iterator::_StackFrame
95{
96 std::vector<SdfPath> paths;
97 size_t index;
98
99 bool operator==(const _StackFrame &other) const {
100 return paths == other.paths && index == other.index;
101 }
102};
103
104const SdfPath &
105HdSceneIndexPrimView::const_iterator::operator*() const
106{
107 const _StackFrame &frame = _stack.back();
108 return frame.paths[frame.index];
109}
110
111void
112HdSceneIndexPrimView::const_iterator::SkipDescendants()
113{
114 _skipDescendants = true;
115}
116
117bool
118HdSceneIndexPrimView::const_iterator::operator==(
119 const const_iterator &other) const
120{
121 return _stack == other._stack;
122}
123
124bool
125HdSceneIndexPrimView::const_iterator::operator!=(
126 const const_iterator &other) const
127{
128 return !(*this == other);
129}
130
131PXR_NAMESPACE_CLOSE_SCOPE
132
133#endif
Abstract interface to scene data.
Definition: sceneIndex.h:48
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:274
Standard pointer typedefs.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition: declarePtrs.h:58