7 #ifndef PXR_USD_USD_STAGE_H
8 #define PXR_USD_USD_STAGE_H
39 #include <tbb/concurrent_hash_map.h>
40 #include <tbb/spin_rw_mutex.h>
46 #include <unordered_map>
55 class Usd_AssetPathContext;
57 class Usd_InstanceCache;
58 class Usd_InstanceChanges;
59 class Usd_Interpolator;
177 static UsdStageRefPtr
182 static UsdStageRefPtr
184 const SdfLayerHandle& sessionLayer,
188 static UsdStageRefPtr
190 const SdfLayerHandle& sessionLayer,
195 static UsdStageRefPtr
218 static UsdStageRefPtr
222 static UsdStageRefPtr
227 static UsdStageRefPtr
233 static UsdStageRefPtr
235 const SdfLayerHandle &sessionLayer,
239 static UsdStageRefPtr
241 const SdfLayerHandle &sessionLayer,
261 static UsdStageRefPtr
265 static UsdStageRefPtr
266 Open(
const std::string& filePath,
288 static UsdStageRefPtr
294 static UsdStageRefPtr
329 static UsdStageRefPtr
330 Open(
const SdfLayerHandle& rootLayer,
334 static UsdStageRefPtr
335 Open(
const SdfLayerHandle& rootLayer,
336 const SdfLayerHandle& sessionLayer,
340 static UsdStageRefPtr
341 Open(
const SdfLayerHandle& rootLayer,
346 static UsdStageRefPtr
347 Open(
const SdfLayerHandle& rootLayer,
348 const SdfLayerHandle& sessionLayer,
373 static UsdStageRefPtr
379 static UsdStageRefPtr
381 const SdfLayerHandle& sessionLayer,
386 static UsdStageRefPtr
393 static UsdStageRefPtr
395 const SdfLayerHandle& sessionLayer,
655 return _populationMask;
678 std::function<
bool (
UsdRelationship const &)>
const &relPred =
nullptr,
679 std::function<
bool (
UsdAttribute const &)>
const &attrPred =
nullptr);
686 std::function<
bool (
UsdRelationship const &)>
const &relPred =
nullptr,
687 std::function<
bool (
UsdAttribute const &)>
const &attrPred =
nullptr);
840 _GetPrimDataAtPathOrInPrototype(
const SdfPath &
path)
const;
844 _GetInstancesForPrototype(
const UsdPrim& prototype)
const;
1019 SdfLayerHandleVector
GetLayerStack(
bool includeSessionLayers=
true)
const;
1033 SdfLayerHandleVector
GetUsedLayers(
bool includeClipLayers=
true)
const;
1092 void MuteLayer(
const std::string &layerIdentifier);
1097 void UnmuteLayer(
const std::string &layerIdentifier);
1108 const std::vector<std::string> &unmuteLayers);
1119 bool IsLayerMuted(
const std::string& layerIdentifier)
const;
1143 bool addSourceFileComment=
true,
1156 bool addSourceFileComment=
true)
const;
1273 template<
typename T>
1520 TfToken *colorManagementSystem);
1538 const TfToken &colorManagementSystem);
1579 struct _IncludePayloadsPredicate;
1592 template <
class... Args>
1603 static UsdStageRefPtr
1614 SdfPropertySpecHandleVector
1617 std::vector<std::pair<SdfPropertySpecHandle, SdfLayerOffset>>
1618 _GetPropertyStackWithLayerOffsets(
1621 static SdfPrimSpecHandleVector
1622 _GetPrimStack(
const UsdPrim &prim);
1624 static std::vector<std::pair<SdfPrimSpecHandle, SdfLayerOffset>>
1625 _GetPrimStackWithLayerOffsets(
const UsdPrim &prim);
1628 _GetSchemaProperty(
const UsdProperty &prop)
const;
1637 SdfAttributeSpecHandle
1638 _CreateNewSpecFromSchemaAttribute(
1642 SdfRelationshipSpecHandle
1643 _CreateNewSpecFromSchemaRelationship(
1647 template <
class PropType>
1649 _CreateNewPropertySpecFromSchema(
const UsdProperty &prop);
1652 _CreatePrimSpecForEditing(
const UsdPrim& prim);
1654 template <
class PropType>
1656 _CreatePropertySpecForEditing(
const UsdProperty &prop);
1658 SdfPropertySpecHandle
1659 _CreatePropertySpecForEditing(
const UsdProperty &prop);
1661 SdfAttributeSpecHandle
1662 _CreateAttributeSpecForEditing(
const UsdAttribute &attr);
1664 SdfRelationshipSpecHandle
1670 std::pair<bool, UsdPrim>
1671 _IsValidPathForCreatingPrim(
const SdfPath &path)
const;
1676 bool _ValidateEditPrim(
const UsdPrim &prim,
const char* operation)
const;
1677 bool _ValidateEditPrimAtPath(
const SdfPath &primPath,
1678 const char* operation)
const;
1682 bool _RemoveProperty(
const SdfPath& path);
1706 bool _SetMetadata(
const UsdObject &
object,
1719 PcpCache const *_GetPcpCache()
const {
return _cache.get(); }
1720 PcpCache *_GetPcpCache() {
return _cache.get(); }
1729 const std::string &context)
const;
1731 const std::vector<std::string>& otherErrors,
1732 const std::string &context)
const;
1742 void _ComposePrimIndexesInParallel(
1743 const std::vector<SdfPath>& primIndexPaths,
1744 const std::string& context,
1745 Usd_InstanceChanges* instanceChanges =
nullptr);
1749 void _ComposeSubtree(
1753 void _ComposeSubtreeImpl(
1757 void _ComposeSubtreesInParallel(
1758 const std::vector<Usd_PrimDataPtr> &prims,
1759 const std::vector<SdfPath> *primIndexPaths =
nullptr);
1799 void _DestroyPrimsInParallel(
const std::vector<SdfPath>& paths);
1807 bool _IsObjectDescendantOfInstance(
const SdfPath& path)
const;
1814 SdfPath _GetPrimPathUsingPrimIndexAtPath(
const SdfPath& primIndexPath)
const;
1833 bool _ProcessPendingChanges();
1837 bool _RemovePrim(
const SdfPath& fullPath);
1839 SdfPrimSpecHandle _GetPrimSpec(
const SdfPath& fullPath);
1847 const TfToken &propName)
const;
1853 void _Recompose(
const PcpChanges &changes,
T *pathsToRecompose);
1855 void _RecomposePrims(
T *pathsToRecompose);
1862 template <
class Iter>
1863 void _ComputeSubtreesToRecompose(Iter
start, Iter finish,
1864 std::vector<Usd_PrimDataPtr>* recompose);
1868 bool _IsValidForLoad(
const SdfPath& path)
const;
1869 bool _IsValidForUnload(
const SdfPath& path)
const;
1879 void _DiscoverPayloads(
const SdfPath& rootPath,
1882 bool unloadedOnly =
false,
1907 size_t numAssetPaths,
1908 bool anchorAssetPathsOnly =
false)
const;
1912 bool anchorAssetPathsOnly =
false)
const;
1927 std::is_same<T, VtArray<SdfAssetPath>>
::value ||
1929 std::is_same<T, VtArray<SdfTimeCode>>
::value ||
1931 std::is_same<T, VtArray<SdfPathExpression>>
::value ||
1953 bool strongestOnly)
const;
1962 const bool strongestOnly =
1965 return _GetMetadata(obj, fieldName, keyPath, useFallbacks, &out,
1969 template <
class Composer>
1973 Composer *composer)
const;
1975 template <
class Composer>
1978 Composer *composer)
const;
1980 template <
class Composer>
1983 Composer *composer)
const;
1985 template <
class Composer>
1986 bool _GetSpecialPropMetadataImpl(
const UsdObject &obj,
1990 Composer *composer)
const;
1991 template <
class Composer>
1992 bool _GetMetadataImpl(
const UsdObject &obj,
1995 bool includeFallbacks,
1996 Composer *composer)
const;
1998 template <
class Composer>
1999 bool _GetGeneralMetadataImpl(
const UsdObject &obj,
2002 bool includeFallbacks,
2003 Composer *composer)
const;
2009 const TfToken &keyPath,
bool useFallbacks)
const;
2012 _ListMetadataFields(
const UsdObject &obj,
bool useFallbacks)
const;
2014 void _GetAllMetadata(
const UsdObject &obj,
2017 bool anchorAssetPathsOnly =
false)
const;
2023 struct _ExtraResolveInfo;
2033 _ExtraResolveInfo *extraInfo =
nullptr)
const;
2041 void _GetResolveInfoWithResolveTarget(
2046 _ExtraResolveInfo *extraInfo =
nullptr)
const;
2053 template <
class MakeUsdResolverFn>
2057 _ExtraResolveInfo *extraInfo,
2058 const MakeUsdResolverFn &makeUsdResolveFn)
const;
2060 struct _BracketingSamplesResolver;
2061 struct _PropertyStackResolver;
2062 struct _ResolveInfoResolver;
2063 struct _SamplesInIntervalResolver;
2064 struct _TimeSampleMapResolver;
2068 bool forFlattening=
false)
const;
2070 template <
class Resolver,
class MakeUsdResolverFn>
2071 void _GetResolvedValueAtDefaultImpl(
2074 const MakeUsdResolverFn &makeUsdResolverFn)
const;
2076 template <
class Resolver,
class MakeUsdResolverFn>
2077 void _GetResolvedValueAtTimeImpl(
2081 const MakeUsdResolverFn &makeUsdResolverFn)
const;
2092 Usd_Interpolator
const &interpolator,
2096 bool _GetValueFromResolveInfo(
2103 bool _GetValueFromResolveInfo(
2115 bool _GetValueFromResolveInfoImpl(
2117 Usd_Interpolator
const &interpolator,
2119 const _ExtraResolveInfo *extraInfo,
T *
result)
const;
2121 bool _GetCompletedResolveInfo(
const UsdAttribute &attr,
2126 _ExtraResolveInfo *extraInfoOut)
const;
2141 bool _GetTimeSamplesInInterval(
2144 std::vector<double>* times,
2148 size_t _GetNumTimeSamples(
2156 bool _GetBracketingTimeSamples(
2165 bool _ValueMightBeTimeVarying(
const UsdAttribute &attr)
const;
2167 bool _ValueMightBeTimeVaryingFromResolveInfo(
2171 void _RegisterPerLayerNotices();
2172 void _RegisterResolverChangeNotice();
2175 inline char const *_GetMallocTagId()
const;
2178 class _PendingChanges;
2185 class _NamespaceEditsChangeBlock {
2197 using ExpectedNamespaceEditChangeVector =
2198 std::vector<ExpectedNamespaceEditChange>;
2200 _NamespaceEditsChangeBlock(
const UsdStagePtr &stage,
2201 ExpectedNamespaceEditChangeVector &&expectedChanges);
2202 _NamespaceEditsChangeBlock(_NamespaceEditsChangeBlock &&);
2203 ~_NamespaceEditsChangeBlock();
2207 std::unique_ptr<_PendingChanges> _localPendingChanges;
2222 bool _editTargetIsLocalLayer;
2224 std::unique_ptr<PcpCache> _cache;
2225 std::unique_ptr<Usd_ClipCache> _clipCache;
2226 std::unique_ptr<Usd_InstanceCache> _instanceCache;
2230 size_t _usedLayersRevision;
2237 inline size_t hash(
SdfPath const &path)
const {
2241 using PathToNodeMap = tbb::concurrent_hash_map<
2243 PathToNodeMap _primMap;
2248 typedef std::vector<
2249 std::pair<SdfLayerHandle, TfNotice::Key> > _LayerAndNoticeKeyVec;
2250 _LayerAndNoticeKeyVec _layersAndNoticeKeys;
2251 size_t _lastChangeSerialNumber;
2256 _PendingChanges* _pendingChanges;
2258 std::optional<WorkDispatcher> _dispatcher;
2262 std::unique_ptr<std::string> _mallocTagID;
2273 bool _isClosingStage;
2274 bool _isWritingFallbackPrimTypes;
2297 template <
class RefsOrPayloadsEditorType,
class RefsOrPayloadsProxyType>
2301 template<
typename T>
2315 " match retrieved type %s",
2316 ArchGetDemangled<T>().
c_str(),
2323 template<
typename T>
2337 TF_CODING_ERROR(
"Requested type %s for stage metadatum %s[%s] does not"
2338 " match retrieved type %s",
2339 ArchGetDemangled<T>().
c_str(),
2349 #endif //PXR_USD_USD_STAGE_H
TfDelegatedCountPtr< Usd_PrimData > Usd_PrimDataIPtr
std::string upper(string_view a)
Return an all-upper case version of a (locale-independent).
GT_API const UT_StringHolder filename
USD_API void MuteAndUnmuteLayers(const std::vector< std::string > &muteLayers, const std::vector< std::string > &unmuteLayers)
virtual USD_API ~UsdStage()
static SDF_API const SdfPath & AbsoluteRootPath()
USD_API double GetFramesPerSecond() const
USD_API bool HasDefaultPrim() const
USD_API UsdPrim GetPrimAtPath(const SdfPath &path) const
T const & UncheckedGet() const &
USD_API void SetInterpolationType(UsdInterpolationType interpolationType)
USD_API std::vector< UsdPrim > GetPrototypes() const
Returns all native instancing prototype prims.
USD_API ArResolverContext GetPathResolverContext() const
USD_API double GetStartTimeCode() const
static USD_API UsdStageRefPtr CreateInMemory(InitialLoadSet load=LoadAll)
USD_API bool HasMetadataDictKey(const TfToken &key, const TfToken &keyPath) const
GT_API const UT_StringHolder time
bool GetMetadata(const TfToken &key, T *value) const
USD_API UsdPrimRange Traverse()
#define PXR_NAMESPACE_OPEN_SCOPE
USD_API bool Export(const std::string &filename, bool addSourceFileComment=true, const SdfLayer::FileFormatArguments &args=SdfLayer::FileFormatArguments()) const
GLsizei const GLfloat * value
GLsizei const GLchar *const * path
std::map< std::string, std::string > FileFormatArguments
SdfPrimSpecHandleVector oldPrimStack
USD_API UsdPrim CreateClassPrim(const SdfPath &rootPrimPath)
USD_API bool ClearMetadata(const TfToken &key) const
USD_API UsdRelationship GetRelationshipAtPath(const SdfPath &path) const
USD_API SdfPathSet GetLoadSet()
USD_API void Unload(const SdfPath &path=SdfPath::AbsoluteRootPath())
IMATH_HOSTDEVICE constexpr bool equal(T1 a, T2 b, T3 t) IMATH_NOEXCEPT
USD_API bool IsLayerMuted(const std::string &layerIdentifier) const
USD_API void SetDefaultPrim(const UsdPrim &prim)
**But if you need a result
USD_API void WriteFallbackPrimTypes()
USD_API void MuteLayer(const std::string &layerIdentifier)
friend struct Usd_ListEditImpl
USD_API SdfPathSet FindLoadable(const SdfPath &rootPath=SdfPath::AbsoluteRootPath())
SDF_DECLARE_HANDLES(SdfLayer)
static USD_API void SetGlobalVariantFallbacks(const PcpVariantFallbackMap &fallbacks)
size_t GetHash() const
Equality operator.
USD_API const UsdEditTarget & GetEditTarget() const
Return the stage's EditTarget.
GLenum GLuint GLint GLint layer
GLenum GLint GLint GLint GLint GLuint dstName
USD_API double GetEndTimeCode() const
USD_API SdfLayerRefPtr Flatten(bool addSourceFileComment=true) const
USD_API UsdPrim GetDefaultPrim() const
USD_API void SetColorConfiguration(const SdfAssetPath &colorConfig) const
USD_API TfToken GetColorManagementSystem() const
bool GetMetadataByDictKey(const TfToken &key, const TfToken &keyPath, T *value) const
USD_API UsdEditTarget GetEditTargetForLocalLayer(size_t i)
friend class Usd_AssetPathContext
USD_API SdfLayerHandleVector GetLayerStack(bool includeSessionLayers=true) const
USD_API void LoadAndUnload(const SdfPathSet &loadSet, const SdfPathSet &unloadSet, UsdLoadPolicy policy=UsdLoadWithDescendants)
USD_API SdfLayerHandle GetSessionLayer() const
Return this stage's root session layer.
USD_API bool HasAuthoredMetadataDictKey(const TfToken &key, const TfToken &keyPath) const
std::vector< TfToken > TfTokenVector
Convenience types.
USD_API bool HasAuthoredMetadata(const TfToken &key) const
static USD_API UsdStageRefPtr CreateNew(const std::string &identifier, InitialLoadSet load=LoadAll)
USD_API UsdProperty GetPropertyAtPath(const SdfPath &path) const
USD_API bool RemovePrim(const SdfPath &path)
USD_API void SetColorManagementSystem(const TfToken &cms) const
friend class Usd_TypeQueryAccess
std::map< class TfToken, VtValue, TfDictionaryLessThan > UsdMetadataValueMap
char const * GetText() const
friend struct Usd_AttrGetValueHelper
static USD_API UsdStageRefPtr Open(const std::string &filePath, InitialLoadSet load=LoadAll)
USD_API bool HasAuthoredTimeCodeRange() const
USD_API void SetLoadRules(UsdStageLoadRules const &rules)
std::vector< PcpErrorBasePtr > PcpErrorVector
USD_API bool SetMetadataByDictKey(const TfToken &key, const TfToken &keyPath, VtValueRef value) const
USD_API bool SetMetadata(const TfToken &key, VtValueRef value) const
USD_API void SetEditTarget(const UsdEditTarget &editTarget)
USD_API bool HasMetadata(const TfToken &key) const
USD_API void SetFramesPerSecond(double framesPerSecond) const
std::set< class SdfPath > SdfPathSet
A set of SdfPaths.
USD_API PcpErrorVector GetCompositionErrors() const
USD_API bool HasLocalLayer(const SdfLayerHandle &layer) const
USD_API void UnmuteLayer(const std::string &layerIdentifier)
USD_API std::string ResolveIdentifierToEditTarget(std::string const &identifier) const
USD_API void SetEndTimeCode(double)
USD_API UsdPrimRange TraverseAll()
std::vector< std::pair< SdfLayerHandle, SdfChangeList > > SdfLayerChangeListVec
USD_API void SetTimeCodesPerSecond(double timeCodesPerSecond) const
USD_API void ClearDefaultPrim()
USD_API SdfLayerHandle GetRootLayer() const
Return this stage's root layer.
std::string lower(string_view a)
Return an all-upper case version of a (locale-independent).
USD_API UsdInterpolationType GetInterpolationType() const
friend class Usd_FlattenAccess
static USD_API bool IsSupportedFile(const std::string &filePath)
friend class Usd_PcpCacheAccess
USD_API UsdObject GetObjectAtPath(const SdfPath &path) const
UsdStageLoadRules const & GetLoadRules() const
friend struct Usd_AttrGetUntypedValueHelper
USD_API UsdPrim Load(const SdfPath &path=SdfPath::AbsoluteRootPath(), UsdLoadPolicy policy=UsdLoadWithDescendants)
static USD_API PcpVariantFallbackMap GetGlobalVariantFallbacks()
Get the global variant fallback preferences used in new UsdStages.
VT_API std::string GetTypeName() const
Return the type name of the held typeid.
#define PXR_NAMESPACE_CLOSE_SCOPE
USD_API SdfAssetPath GetColorConfiguration() const
USD_API const std::vector< std::string > & GetMutedLayers() const
Returns a vector of all layers that have been muted on this stage.
USD_API UsdPrim GetPseudoRoot() const
**If you just want to fire and args
friend class Usd_StageOpenRequest
OIIO_UTIL_API const char * c_str(string_view str)
USD_API UsdPrim DefinePrim(const SdfPath &path, const TfToken &typeName=TfToken())
UsdStagePopulationMask GetPopulationMask() const
Return this stage's population mask.
USD_API UsdPrim OverridePrim(const SdfPath &path)
static USD_API void GetColorConfigFallbacks(SdfAssetPath *colorConfiguration, TfToken *colorManagementSystem)
static USD_API UsdStageRefPtr OpenMasked(const std::string &filePath, UsdStagePopulationMask const &mask, InitialLoadSet load=LoadAll)
USD_API double GetTimeCodesPerSecond() const
std::map< double, VtValue > SdfTimeSampleMap
A map from sample times to sample values.
USD_API void SetPopulationMask(UsdStagePopulationMask const &mask)
Set this stage's population mask and recompose the stage.
USD_API void SetStartTimeCode(double)
USD_API bool ClearMetadataByDictKey(const TfToken &key, const TfToken &keyPath) const
USD_API bool ExportToString(std::string *result, bool addSourceFileComment=true) const
USD_API void ExpandPopulationMask(Usd_PrimFlagsPredicate const &traversalPredicate, std::function< bool(UsdRelationship const &)> const &relPred=nullptr, std::function< bool(UsdAttribute const &)> const &attrPred=nullptr)
USD_API void SaveSessionLayers()
static USD_API void SetColorConfigFallbacks(const SdfAssetPath &colorConfiguration, const TfToken &colorManagementSystem)
std::map< std::string, std::vector< std::string > > PcpVariantFallbackMap
Load a prim plus all its descendants.
USD_API SdfLayerHandleVector GetUsedLayers(bool includeClipLayers=true) const
USD_API UsdAttribute GetAttributeAtPath(const SdfPath &path) const