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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_IMAGING_USD_IMAGING_REROOTING_SCENE_INDEX_H
8 #define PXR_USD_IMAGING_USD_IMAGING_REROOTING_SCENE_INDEX_H
9 
11 
13 
15 
17 
18 /// \class UsdImagingRerootingSceneIndex
19 ///
20 /// Drops all prims not under srcPrefix and moves those under srcPrefix to
21 /// dstPrefix.
22 ///
23 /// Data sources containing paths will be updated accordingly. That is, if it
24 /// contains a path with srcPrefix as prefix, the prefix will be replaced by
25 /// dstPrefix.
26 ///
27 /// Note that this can be used as prefixing scene index by setting srcPrefix
28 /// to the root path. It can also use to isolate part of the namespace by
29 /// setting the srcPrefix and dstPrefix to be equal.
30 ///
33 {
34 public:
35  static UsdImagingRerootingSceneIndexRefPtr New(
36  HdSceneIndexBaseRefPtr const &inputScene,
37  const SdfPath &srcPrefix,
38  const SdfPath &dstPrefix)
39  {
40  return TfCreateRefPtr(
42  inputScene, srcPrefix, dstPrefix));
43  }
44 
46  HdSceneIndexPrim GetPrim(const SdfPath& primPath) const override;
47 
49  SdfPathVector GetChildPrimPaths(const SdfPath& primPath) const override;
50 
51 protected:
54  HdSceneIndexBaseRefPtr const &inputScene,
55  const SdfPath &srcPrefix,
56  const SdfPath &dstPrefix);
57 
60 
61  // satisfying HdSingleInputFilteringSceneIndexBase
62  void _PrimsAdded(
63  const HdSceneIndexBase& sender,
64  const HdSceneIndexObserver::AddedPrimEntries& entries) override;
65 
66  void _PrimsRemoved(
67  const HdSceneIndexBase& sender,
68  const HdSceneIndexObserver::RemovedPrimEntries& entries) override;
69 
70  void _PrimsDirtied(
71  const HdSceneIndexBase& sender,
72  const HdSceneIndexObserver::DirtiedPrimEntries& entries) override;
73 
74 private:
75  SdfPath _SrcPathToDstPath(const SdfPath &primPath) const;
76  SdfPath _DstPathToSrcPath(const SdfPath &primPath) const;
77 
78  const SdfPath _srcPrefix;
79  const SdfPath _dstPrefix;
80  // Prefixes of _dstPrefix
81  const SdfPathVector _dstPrefixes;
82  // Is _srcPrefix equal to _dstPrefix?
83  const bool _srcEqualsDst;
84  // Is _srcPrefix == / ?
85  const bool _srcPrefixIsRoot;
86 };
87 
89 
90 #endif
TfRefPtr< T > TfCreateRefPtr(T *ptr)
Definition: refPtr.h:1190
void _PrimsRemoved(const HdSceneIndexBase &sender, const HdSceneIndexObserver::RemovedPrimEntries &entries) override
#define USDIMAGING_API
Definition: api.h:23
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_REF_PTRS(UsdImagingRerootingSceneIndex)
USDIMAGING_API ~UsdImagingRerootingSceneIndex() override
std::vector< class SdfPath > SdfPathVector
void _PrimsDirtied(const HdSceneIndexBase &sender, const HdSceneIndexObserver::DirtiedPrimEntries &entries) override
Definition: path.h:273
void _PrimsAdded(const HdSceneIndexBase &sender, const HdSceneIndexObserver::AddedPrimEntries &entries) override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
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)