24 #ifndef PXR_USD_USD_STAGE_H
25 #define PXR_USD_USD_STAGE_H
54 #include <tbb/concurrent_vector.h>
55 #include <tbb/concurrent_unordered_set.h>
56 #include <tbb/concurrent_hash_map.h>
57 #include <tbb/spin_rw_mutex.h>
63 #include <unordered_map>
71 class Usd_AssetPathContext;
73 class Usd_InstanceCache;
74 class Usd_InstanceChanges;
75 class Usd_InterpolatorBase;
193 static UsdStageRefPtr
198 static UsdStageRefPtr
200 const SdfLayerHandle& sessionLayer,
204 static UsdStageRefPtr
206 const SdfLayerHandle& sessionLayer,
211 static UsdStageRefPtr
234 static UsdStageRefPtr
238 static UsdStageRefPtr
243 static UsdStageRefPtr
249 static UsdStageRefPtr
251 const SdfLayerHandle &sessionLayer,
255 static UsdStageRefPtr
257 const SdfLayerHandle &sessionLayer,
277 static UsdStageRefPtr
281 static UsdStageRefPtr
304 static UsdStageRefPtr
310 static UsdStageRefPtr
345 static UsdStageRefPtr
346 Open(
const SdfLayerHandle& rootLayer,
350 static UsdStageRefPtr
351 Open(
const SdfLayerHandle& rootLayer,
352 const SdfLayerHandle& sessionLayer,
356 static UsdStageRefPtr
357 Open(
const SdfLayerHandle& rootLayer,
362 static UsdStageRefPtr
363 Open(
const SdfLayerHandle& rootLayer,
364 const SdfLayerHandle& sessionLayer,
389 static UsdStageRefPtr
395 static UsdStageRefPtr
397 const SdfLayerHandle& sessionLayer,
402 static UsdStageRefPtr
409 static UsdStageRefPtr
411 const SdfLayerHandle& sessionLayer,
671 return _populationMask;
694 std::function<
bool (
UsdRelationship const &)>
const &relPred =
nullptr,
695 std::function<
bool (
UsdAttribute const &)>
const &attrPred =
nullptr);
702 std::function<
bool (
UsdRelationship const &)>
const &relPred =
nullptr,
703 std::function<
bool (
UsdAttribute const &)>
const &attrPred =
nullptr);
849 _GetPrimDataAtPathOrInPrototype(
const SdfPath &
path)
const;
853 _GetInstancesForPrototype(
const UsdPrim& prototype)
const;
1024 SdfLayerHandleVector
GetLayerStack(
bool includeSessionLayers=
true)
const;
1038 SdfLayerHandleVector
GetUsedLayers(
bool includeClipLayers=
true)
const;
1113 const std::vector<std::string> &unmuteLayers);
1148 bool addSourceFileComment=
true,
1161 bool addSourceFileComment=
true)
const;
1249 template<
typename T>
1281 template<
typename T>
1326 template<
typename T>
1559 TfToken *colorManagementSystem);
1577 const TfToken &colorManagementSystem);
1618 struct _IncludePayloadsPredicate;
1631 template <
class... Args>
1642 static UsdStageRefPtr
1653 SdfPropertySpecHandleVector
1656 std::vector<std::pair<SdfPropertySpecHandle, SdfLayerOffset>>
1657 _GetPropertyStackWithLayerOffsets(
1660 static SdfPrimSpecHandleVector
1661 _GetPrimStack(
const UsdPrim &prim);
1663 static std::vector<std::pair<SdfPrimSpecHandle, SdfLayerOffset>>
1664 _GetPrimStackWithLayerOffsets(
const UsdPrim &prim);
1667 _GetSchemaProperty(
const UsdProperty &prop)
const;
1675 SdfAttributeSpecHandle
1676 _CreateNewSpecFromSchemaAttribute(
1680 SdfRelationshipSpecHandle
1681 _CreateNewSpecFromSchemaRelationship(
1685 template <
class PropType>
1687 _CreateNewPropertySpecFromSchema(
const UsdProperty &prop);
1690 _CreatePrimSpecForEditing(
const UsdPrim& prim);
1692 template <
class PropType>
1694 _CreatePropertySpecForEditing(
const UsdProperty &prop);
1696 SdfPropertySpecHandle
1697 _CreatePropertySpecForEditing(
const UsdProperty &prop);
1699 SdfAttributeSpecHandle
1700 _CreateAttributeSpecForEditing(
const UsdAttribute &attr);
1702 SdfRelationshipSpecHandle
1708 std::pair<bool, UsdPrim>
1709 _IsValidPathForCreatingPrim(
const SdfPath &path)
const;
1714 bool _ValidateEditPrim(
const UsdPrim &prim,
const char* operation)
const;
1715 bool _ValidateEditPrimAtPath(
const SdfPath &primPath,
1716 const char* operation)
const;
1720 bool _RemoveProperty(
const SdfPath& path);
1734 struct _IsEditTargetMappable {
1735 static const bool value =
1737 std::is_same<T, VtArray<SdfTimeCode>>
::value ||
1739 std::is_same<T, VtArray<SdfPathExpression>>
::value ||
1762 bool _SetEditTargetMappedValue(
1786 bool _SetMetadata(
const UsdObject &
object,
1792 bool _SetEditTargetMappedMetadata(
1794 const TfToken &keyPath,
const T &newValue);
1797 bool _SetMetadataImpl(
1809 PcpCache const *_GetPcpCache()
const {
return _cache.get(); }
1810 PcpCache *_GetPcpCache() {
return _cache.get(); }
1821 const std::vector<std::string>& otherErrors,
1832 void _ComposePrimIndexesInParallel(
1833 const std::vector<SdfPath>& primIndexPaths,
1835 Usd_InstanceChanges* instanceChanges =
nullptr);
1839 void _ComposeSubtree(
1843 void _ComposeSubtreeImpl(
1847 void _ComposeSubtreesInParallel(
1848 const std::vector<Usd_PrimDataPtr> &prims,
1849 const std::vector<SdfPath> *primIndexPaths =
nullptr);
1889 void _DestroyPrimsInParallel(
const std::vector<SdfPath>& paths);
1897 bool _IsObjectDescendantOfInstance(
const SdfPath& path)
const;
1904 SdfPath _GetPrimPathUsingPrimIndexAtPath(
const SdfPath& primIndexPath)
const;
1914 void _ProcessPendingChanges();
1918 bool _RemovePrim(
const SdfPath& fullPath);
1920 SdfPrimSpecHandle _GetPrimSpec(
const SdfPath& fullPath);
1928 const TfToken &propName)
const;
1934 void _Recompose(
const PcpChanges &changes,
T *pathsToRecompose);
1936 void _RecomposePrims(
T *pathsToRecompose);
1943 template <
class Iter>
1944 void _ComputeSubtreesToRecompose(Iter
start, Iter finish,
1945 std::vector<Usd_PrimDataPtr>* recompose);
1949 bool _IsValidForLoad(
const SdfPath& path)
const;
1950 bool _IsValidForUnload(
const SdfPath& path)
const;
1960 void _DiscoverPayloads(
const SdfPath& rootPath,
1963 bool unloadedOnly =
false,
1988 size_t numAssetPaths,
1989 bool anchorAssetPathsOnly =
false)
const;
1993 bool anchorAssetPathsOnly =
false)
const;
1997 size_t numTimeCodes)
const;
1999 void _MakeResolvedPathExpressions(
2002 size_t numPathExprs)
const;
2020 std::is_same<T, VtArray<SdfAssetPath>>
::value ||
2022 std::is_same<T, VtArray<SdfTimeCode>>
::value ||
2024 std::is_same<T, VtArray<SdfPathExpression>>
::value ||
2060 bool _GetStrongestResolvedMetadata(
const UsdObject &obj,
2071 bool _GetTypeSpecificResolvedMetadata(
const UsdObject &obj,
2077 template <
class Composer>
2081 Composer *composer)
const;
2083 template <
class Composer>
2086 Composer *composer)
const;
2088 template <
class Composer>
2091 Composer *composer)
const;
2093 template <
class Composer>
2094 bool _GetSpecialPropMetadataImpl(
const UsdObject &obj,
2098 Composer *composer)
const;
2099 template <
class Composer>
2100 bool _GetMetadataImpl(
const UsdObject &obj,
2103 bool includeFallbacks,
2104 Composer *composer)
const;
2106 template <
class Composer>
2107 bool _GetGeneralMetadataImpl(
const UsdObject &obj,
2110 bool includeFallbacks,
2111 Composer *composer)
const;
2117 const TfToken &keyPath,
bool useFallbacks)
const;
2120 _ListMetadataFields(
const UsdObject &obj,
bool useFallbacks)
const;
2122 void _GetAllMetadata(
const UsdObject &obj,
2125 bool anchorAssetPathsOnly =
false)
const;
2135 void _GetResolveInfoWithResolveTarget(
2141 template <
class T>
struct _ExtraResolveInfo;
2152 _ExtraResolveInfo<T> *extraInfo =
nullptr)
const;
2161 void _GetResolveInfoWithResolveTarget(
2166 _ExtraResolveInfo<T> *extraInfo =
nullptr)
const;
2173 template <
class T,
class MakeUsdResolverFn>
2177 _ExtraResolveInfo<T> *extraInfo,
2178 const MakeUsdResolverFn &makeUsdResolveFn)
const;
2180 template <
class T>
struct _ResolveInfoResolver;
2181 struct _PropertyStackResolver;
2183 template <
class Resolver,
class MakeUsdResolverFn>
2184 void _GetResolvedValueAtDefaultImpl(
2187 const MakeUsdResolverFn &makeUsdResolverFn)
const;
2189 template <
class Resolver,
class MakeUsdResolverFn>
2190 void _GetResolvedValueAtTimeImpl(
2194 const MakeUsdResolverFn &makeUsdResolverFn)
const;
2205 Usd_InterpolatorBase* interpolator,
2222 Usd_InterpolatorBase* interpolator,
2226 bool _GetDefaultValueFromResolveInfoImpl(
const UsdResolveInfo &info,
2243 bool _GetTimeSamplesInInterval(
const UsdAttribute &attr,
2245 std::vector<double>* times)
const;
2247 bool _GetTimeSamplesInIntervalFromResolveInfo(
2251 std::vector<double>* times)
const;
2253 size_t _GetNumTimeSamples(
const UsdAttribute &attr)
const;
2255 size_t _GetNumTimeSamplesFromResolveInfo(
const UsdResolveInfo &info,
2261 bool _GetBracketingTimeSamples(
const UsdAttribute &attr,
2266 bool* hasSamples)
const;
2268 bool _GetBracketingTimeSamplesFromResolveInfo(
const UsdResolveInfo &info,
2274 bool* hasSamples)
const;
2276 bool _ValueMightBeTimeVarying(
const UsdAttribute &attr)
const;
2278 bool _ValueMightBeTimeVaryingFromResolveInfo(
const UsdResolveInfo &info,
2281 void _RegisterPerLayerNotices();
2282 void _RegisterResolverChangeNotice();
2285 inline char const *_GetMallocTagId()
const;
2301 bool _editTargetIsLocalLayer;
2303 std::unique_ptr<PcpCache> _cache;
2304 std::unique_ptr<Usd_ClipCache> _clipCache;
2305 std::unique_ptr<Usd_InstanceCache> _instanceCache;
2309 size_t _usedLayersRevision;
2316 inline size_t hash(
SdfPath const &path)
const {
2320 using PathToNodeMap = tbb::concurrent_hash_map<
2322 PathToNodeMap _primMap;
2327 typedef std::vector<
2328 std::pair<SdfLayerHandle, TfNotice::Key> > _LayerAndNoticeKeyVec;
2329 _LayerAndNoticeKeyVec _layersAndNoticeKeys;
2330 size_t _lastChangeSerialNumber;
2335 class _PendingChanges;
2336 _PendingChanges* _pendingChanges;
2338 std::optional<WorkDispatcher> _dispatcher;
2342 std::unique_ptr<std::string> _mallocTagID;
2353 bool _isClosingStage;
2354 bool _isWritingFallbackPrimTypes;
2375 template <
class RefsOrPayloadsEditorType,
class RefsOrPayloadsProxyType>
2385 UsdStage::_GetTypeSpecificResolvedMetadata(
const UsdObject &obj,
2391 template<
typename T>
2405 " match retrieved type %s",
2406 ArchGetDemangled<T>().c_str(),
2413 template<
typename T>
2421 template<
typename T>
2435 TF_CODING_ERROR(
"Requested type %s for stage metadatum %s[%s] does not"
2436 " match retrieved type %s",
2437 ArchGetDemangled<T>().c_str(),
2445 template<
typename T>
2456 typename std::enable_if<
2467 return _GetStrongestResolvedMetadata(
2468 obj, fieldName, keyPath, useFallbacks, &out);
2473 typename std::enable_if<
2475 UsdStage::_GetMetadata(
const UsdObject &obj,
2483 return _GetTypeSpecificResolvedMetadata(
2484 obj, fieldName, keyPath, useFallbacks, result);
2497 return _SetMetadataImpl<SdfAbstractDataConstValue>(
2498 object, key, keyPath, in);
2507 return _SetEditTargetMappedMetadata(
object, key, keyPath, value);
2512 #endif //PXR_USD_USD_STAGE_H
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)
hboost::math::policies::policy< hboost::math::policies::domain_error< hboost::math::policies::ignore_error >, hboost::math::policies::pole_error< hboost::math::policies::ignore_error >, hboost::math::policies::overflow_error< hboost::math::policies::ignore_error >, hboost::math::policies::underflow_error< hboost::math::policies::ignore_error >, hboost::math::policies::denorm_error< hboost::math::policies::ignore_error >, hboost::math::policies::rounding_error< hboost::math::policies::ignore_error >, hboost::math::policies::evaluation_error< hboost::math::policies::ignore_error >, hboost::math::policies::indeterminate_result_error< hboost::math::policies::ignore_error > > policy
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()
USD_API bool Export(const std::string &filename, bool addSourceFileComment=true, const SdfLayer::FileFormatArguments &args=SdfLayer::FileFormatArguments()) const
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
SDF_DECLARE_HANDLES(SdfLayer)
GLsizei const GLchar *const * path
std::map< std::string, std::string > FileFormatArguments
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())
static USD_API void SetGlobalVariantFallbacks(const PcpVariantFallbackMap &fallbacks)
size_t GetHash() const
Equality operator.
bool SetMetadataByDictKey(const TfToken &key, const TfToken &keyPath, const T &value) const
hboost::intrusive_ptr< Usd_PrimData > Usd_PrimDataIPtr
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
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)
bool SetMetadata(const TfToken &key, const T &value) const
USD_API bool HasAuthoredTimeCodeRange() const
USD_API void SetLoadRules(UsdStageLoadRules const &rules)
std::vector< PcpErrorBasePtr > PcpErrorVector
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 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()
USD_API void SetTimeCodesPerSecond(double timeCodesPerSecond) const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
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
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