Loading...
Searching...
No Matches
sceneIndexPrimView.h
1//
2// Copyright 2022 Pixar
3//
4// Licensed under the Apache License, Version 2.0 (the "Apache License")
5// with the following modification; you may not use this file except in
6// compliance with the Apache License and the following modification to it:
7// Section 6. Trademarks. is deleted and replaced with:
8//
9// 6. Trademarks. This License does not grant permission to use the trade
10// names, trademarks, service marks, or product names of the Licensor
11// and its affiliates, except as required to comply with Section 4(c) of
12// the License and to reproduce the content of the NOTICE file.
13//
14// You may obtain a copy of the Apache License at
15//
16// http://www.apache.org/licenses/LICENSE-2.0
17//
18// Unless required by applicable law or agreed to in writing, software
19// distributed under the Apache License with the above modification is
20// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21// KIND, either express or implied. See the Apache License for the specific
22// language governing permissions and limitations under the Apache License.
23//
24#ifndef PXR_IMAGING_HD_SCENE_INDEX_PRIM_VIEW_H
25#define PXR_IMAGING_HD_SCENE_INDEX_PRIM_VIEW_H
26
27#include "pxr/pxr.h"
28
29#include "pxr/imaging/hd/api.h"
30
31#include "pxr/usd/sdf/path.h"
33
34PXR_NAMESPACE_OPEN_SCOPE
35
37
65{
66public:
67 class const_iterator
68 {
69 public:
70 inline const SdfPath &operator*() const;
71
72 HD_API
73 const_iterator& operator++();
74
75 inline void SkipDescendants();
76 inline bool operator==(const const_iterator &other) const;
77 inline bool operator!=(const const_iterator &other) const;
78
79 private:
80 friend class HdSceneIndexPrimView;
81 struct _StackFrame;
82
83 const_iterator(HdSceneIndexBaseRefPtr const &inputSceneIndex,
84 const SdfPath &root);
85 const_iterator(HdSceneIndexBaseRefPtr const &inputSceneIndex);
86
87 HdSceneIndexBaseRefPtr const _inputSceneIndex;
88 std::vector<_StackFrame> _stack;
89 bool _skipDescendants;
90 };
91
92 HD_API
93 HdSceneIndexPrimView(HdSceneIndexBaseRefPtr const &inputSceneIndex);
94
95 HD_API
96 HdSceneIndexPrimView(HdSceneIndexBaseRefPtr const &inputSceneIndex,
97 const SdfPath &root);
98
99 HD_API
100 const const_iterator &begin() const;
101
102 HD_API
103 const const_iterator &end() const;
104
105private:
106 const const_iterator _begin;
107 const const_iterator _end;
108};
109
110struct
111HdSceneIndexPrimView::const_iterator::_StackFrame
112{
113 std::vector<SdfPath> paths;
114 size_t index;
115
116 bool operator==(const _StackFrame &other) const {
117 return paths == other.paths && index == other.index;
118 }
119};
120
121const SdfPath &
122HdSceneIndexPrimView::const_iterator::operator*() const
123{
124 const _StackFrame &frame = _stack.back();
125 return frame.paths[frame.index];
126}
127
128void
129HdSceneIndexPrimView::const_iterator::SkipDescendants()
130{
131 _skipDescendants = true;
132}
133
134bool
135HdSceneIndexPrimView::const_iterator::operator==(
136 const const_iterator &other) const
137{
138 return _stack == other._stack;
139}
140
141bool
142HdSceneIndexPrimView::const_iterator::operator!=(
143 const const_iterator &other) const
144{
145 return !(*this == other);
146}
147
148PXR_NAMESPACE_CLOSE_SCOPE
149
150#endif
Abstract interface to scene data.
Definition: sceneIndex.h:65
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:290
Standard pointer typedefs.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition: declarePtrs.h:75