HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rerootingSceneIndex.h
Go to the documentation of this file.
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_USD_IMAGING_USD_IMAGING_REROOTING_SCENE_INDEX_H
25 #define PXR_USD_IMAGING_USD_IMAGING_REROOTING_SCENE_INDEX_H
26 
28 
30 
32 
34 
35 /// UsdImagingRerootingSceneIndex
36 ///
37 /// Drops all prims not under srcPrefix and moves those under srcPrefix to
38 /// dstPrefix.
39 ///
40 /// Data sources containing paths will be updated accordingly. That is, if it
41 /// contains a path with srcPrefix as prefix, the prefix will be replaced by
42 /// dstPrefix.
43 ///
44 /// Note that this can be used as prefixing scene index by setting srcPrefix
45 /// to the root path. It can also use to isolate part of the namespace by
46 /// setting the srcPrefix and dstPrefix to be equal.
47 ///
50 {
51 public:
52  static UsdImagingRerootingSceneIndexRefPtr New(
53  HdSceneIndexBaseRefPtr const &inputScene,
54  const SdfPath &srcPrefix,
55  const SdfPath &dstPrefix)
56  {
57  return TfCreateRefPtr(
59  inputScene, srcPrefix, dstPrefix));
60  }
61 
63  HdSceneIndexPrim GetPrim(const SdfPath& primPath) const override;
64 
66  SdfPathVector GetChildPrimPaths(const SdfPath& primPath) const override;
67 
68 protected:
71  HdSceneIndexBaseRefPtr const &inputScene,
72  const SdfPath &srcPrefix,
73  const SdfPath &dstPrefix);
74 
77 
78  // satisfying HdSingleInputFilteringSceneIndexBase
79  void _PrimsAdded(
80  const HdSceneIndexBase& sender,
81  const HdSceneIndexObserver::AddedPrimEntries& entries) override;
82 
83  void _PrimsRemoved(
84  const HdSceneIndexBase& sender,
85  const HdSceneIndexObserver::RemovedPrimEntries& entries) override;
86 
87  void _PrimsDirtied(
88  const HdSceneIndexBase& sender,
89  const HdSceneIndexObserver::DirtiedPrimEntries& entries) override;
90 
91 private:
92  SdfPath _SrcPathToDstPath(const SdfPath &primPath) const;
93  SdfPath _DstPathToSrcPath(const SdfPath &primPath) const;
94 
95  const SdfPath _srcPrefix;
96  const SdfPath _dstPrefix;
97  // Prefixes of _dstPrefix
98  const SdfPathVector _dstPrefixes;
99  // Is _srcPrefix equal to _dstPrefix?
100  const bool _srcEqualsDst;
101  // Is _srcPrefix == / ?
102  const bool _srcPrefixIsRoot;
103 };
104 
106 
107 #endif
TfRefPtr< T > TfCreateRefPtr(T *ptr)
Definition: refPtr.h:1198
void _PrimsRemoved(const HdSceneIndexBase &sender, const HdSceneIndexObserver::RemovedPrimEntries &entries) override
#define USDIMAGING_API
Definition: api.h:40
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_REF_PTRS(UsdImagingRerootingSceneIndex)
USDIMAGING_API ~UsdImagingRerootingSceneIndex() override
void _PrimsDirtied(const HdSceneIndexBase &sender, const HdSceneIndexObserver::DirtiedPrimEntries &entries) override
Definition: path.h:291
void _PrimsAdded(const HdSceneIndexBase &sender, const HdSceneIndexObserver::AddedPrimEntries &entries) override
std::vector< class SdfPath > SdfPathVector
A vector of SdfPaths.
Definition: path.h:212
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
USDIMAGING_API UsdImagingRerootingSceneIndex(HdSceneIndexBaseRefPtr const &inputScene, const SdfPath &srcPrefix, const SdfPath &dstPrefix)
USDIMAGING_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
USDIMAGING_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
static UsdImagingRerootingSceneIndexRefPtr New(HdSceneIndexBaseRefPtr const &inputScene, const SdfPath &srcPrefix, const SdfPath &dstPrefix)