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 
34 PXR_NAMESPACE_OPEN_SCOPE
35 
37 
65 {
66 public:
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  const SdfPath &root);
95 
96  HD_API
97  const const_iterator &begin() const;
98 
99  HD_API
100  const const_iterator &end() const;
101 
102 private:
103  const const_iterator _begin;
104  const const_iterator _end;
105 };
106 
107 struct
108 HdSceneIndexPrimView::const_iterator::_StackFrame
109 {
110  std::vector<SdfPath> paths;
111  size_t index;
112 
113  bool operator==(const _StackFrame &other) const {
114  return paths == other.paths && index == other.index;
115  }
116 };
117 
118 const SdfPath &
119 HdSceneIndexPrimView::const_iterator::operator*() const
120 {
121  const _StackFrame &frame = _stack.back();
122  return frame.paths[frame.index];
123 }
124 
125 void
126 HdSceneIndexPrimView::const_iterator::SkipDescendants()
127 {
128  _skipDescendants = true;
129 }
130 
131 bool
133  const const_iterator &other) const
134 {
135  return _stack == other._stack;
136 }
137 
138 bool
139 HdSceneIndexPrimView::const_iterator::operator!=(
140  const const_iterator &other) const
141 {
142  return !(*this == other);
143 }
144 
145 PXR_NAMESPACE_CLOSE_SCOPE
146 
147 #endif
Standard pointer typedefs.
A range to iterate over all descendants of a given prim (including the prim itself) in a scene index ...
AR_API bool operator==(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
Abstract interface to scene data.
Definition: sceneIndex.h:62
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition: declarePtrs.h:75
VT_API bool operator==(VtDictionary const &, VtDictionary const &)
Equality comparison.