24 #ifndef PXR_USD_USD_STAGE_H
25 #define PXR_USD_USD_STAGE_H
54 #include <hboost/optional.hpp>
56 #include <tbb/concurrent_vector.h>
57 #include <tbb/concurrent_unordered_set.h>
58 #include <tbb/concurrent_hash_map.h>
59 #include <tbb/spin_rw_mutex.h>
64 #include <unordered_map>
72 class Usd_AssetPathContext;
74 class Usd_InstanceCache;
75 class Usd_InstanceChanges;
76 class Usd_InterpolatorBase;
194 static UsdStageRefPtr
199 static UsdStageRefPtr
201 const SdfLayerHandle& sessionLayer,
205 static UsdStageRefPtr
207 const SdfLayerHandle& sessionLayer,
212 static UsdStageRefPtr
235 static UsdStageRefPtr
239 static UsdStageRefPtr
244 static UsdStageRefPtr
250 static UsdStageRefPtr
252 const SdfLayerHandle &sessionLayer,
256 static UsdStageRefPtr
258 const SdfLayerHandle &sessionLayer,
278 static UsdStageRefPtr
282 static UsdStageRefPtr
305 static UsdStageRefPtr
311 static UsdStageRefPtr
346 static UsdStageRefPtr
347 Open(
const SdfLayerHandle& rootLayer,
351 static UsdStageRefPtr
352 Open(
const SdfLayerHandle& rootLayer,
353 const SdfLayerHandle& sessionLayer,
357 static UsdStageRefPtr
358 Open(
const SdfLayerHandle& rootLayer,
363 static UsdStageRefPtr
364 Open(
const SdfLayerHandle& rootLayer,
365 const SdfLayerHandle& sessionLayer,
390 static UsdStageRefPtr
396 static UsdStageRefPtr
398 const SdfLayerHandle& sessionLayer,
403 static UsdStageRefPtr
410 static UsdStageRefPtr
412 const SdfLayerHandle& sessionLayer,
672 return _populationMask;
692 std::function<
bool (
UsdRelationship const &)>
const &relPred =
nullptr,
693 std::function<
bool (
UsdAttribute const &)>
const &attrPred =
nullptr);
839 _GetPrimDataAtPathOrInPrototype(
const SdfPath &
path)
const;
843 _GetInstancesForPrototype(
const UsdPrim& prototype)
const;
1010 SdfLayerHandleVector
GetLayerStack(
bool includeSessionLayers=
true)
const;
1024 SdfLayerHandleVector
GetUsedLayers(
bool includeClipLayers=
true)
const;
1099 const std::vector<std::string> &unmuteLayers);
1134 bool addSourceFileComment=
true,
1147 bool addSourceFileComment=
true)
const;
1235 template<
typename T>
1267 template<
typename T>
1312 template<
typename T>
1545 TfToken *colorManagementSystem);
1563 const TfToken &colorManagementSystem);
1604 struct _IncludePayloadsPredicate;
1617 template <
class... Args>
1628 static UsdStageRefPtr
1639 SdfPropertySpecHandleVector
1642 std::vector<std::pair<SdfPropertySpecHandle, SdfLayerOffset>>
1643 _GetPropertyStackWithLayerOffsets(
1646 static SdfPrimSpecHandleVector
1647 _GetPrimStack(
const UsdPrim &prim);
1649 static std::vector<std::pair<SdfPrimSpecHandle, SdfLayerOffset>>
1650 _GetPrimStackWithLayerOffsets(
const UsdPrim &prim);
1653 _GetSchemaProperty(
const UsdProperty &prop)
const;
1661 SdfAttributeSpecHandle
1662 _CreateNewSpecFromSchemaAttribute(
1666 SdfRelationshipSpecHandle
1667 _CreateNewSpecFromSchemaRelationship(
1671 template <
class PropType>
1673 _CreateNewPropertySpecFromSchema(
const UsdProperty &prop);
1676 _CreatePrimSpecForEditing(
const UsdPrim& prim);
1678 template <
class PropType>
1680 _CreatePropertySpecForEditing(
const UsdProperty &prop);
1682 SdfPropertySpecHandle
1683 _CreatePropertySpecForEditing(
const UsdProperty &prop);
1685 SdfAttributeSpecHandle
1686 _CreateAttributeSpecForEditing(
const UsdAttribute &attr);
1688 SdfRelationshipSpecHandle
1694 std::pair<bool, UsdPrim>
1695 _IsValidPathForCreatingPrim(
const SdfPath &path)
const;
1700 bool _ValidateEditPrim(
const UsdPrim &prim,
const char* operation)
const;
1701 bool _ValidateEditPrimAtPath(
const SdfPath &primPath,
1702 const char* operation)
const;
1706 bool _RemoveProperty(
const SdfPath& path);
1720 struct _IsEditTargetMappable {
1721 static const bool value =
1723 std::is_same<T, VtArray<SdfTimeCode>>
::value ||
1746 bool _SetEditTargetMappedValue(
1770 bool _SetMetadata(
const UsdObject &
object,
1776 bool _SetEditTargetMappedMetadata(
1778 const TfToken &keyPath,
const T &newValue);
1781 bool _SetMetadataImpl(
1793 PcpCache const *_GetPcpCache()
const {
return _cache.get(); }
1794 PcpCache *_GetPcpCache() {
return _cache.get(); }
1805 const std::vector<std::string>& otherErrors,
1816 void _ComposePrimIndexesInParallel(
1817 const std::vector<SdfPath>& primIndexPaths,
1819 Usd_InstanceChanges* instanceChanges =
nullptr);
1823 void _ComposeSubtree(
1827 void _ComposeSubtreeImpl(
1831 void _ComposeSubtreesInParallel(
1832 const std::vector<Usd_PrimDataPtr> &prims,
1833 const std::vector<SdfPath> *primIndexPaths =
nullptr);
1873 void _DestroyPrimsInParallel(
const std::vector<SdfPath>& paths);
1881 bool _IsObjectDescendantOfInstance(
const SdfPath& path)
const;
1888 SdfPath _GetPrimPathUsingPrimIndexAtPath(
const SdfPath& primIndexPath)
const;
1898 void _ProcessPendingChanges();
1902 bool _RemovePrim(
const SdfPath& fullPath);
1904 SdfPrimSpecHandle _GetPrimSpec(
const SdfPath& fullPath);
1912 const TfToken &propName)
const;
1918 void _Recompose(
const PcpChanges &changes,
T *pathsToRecompose);
1920 void _RecomposePrims(
T *pathsToRecompose);
1927 template <
class Iter>
1928 void _ComputeSubtreesToRecompose(Iter
start, Iter finish,
1929 std::vector<Usd_PrimDataPtr>* recompose);
1933 bool _IsValidForLoad(
const SdfPath& path)
const;
1934 bool _IsValidForUnload(
const SdfPath& path)
const;
1944 void _DiscoverPayloads(
const SdfPath& rootPath,
1947 bool unloadedOnly =
false,
1972 size_t numAssetPaths,
1973 bool anchorAssetPathsOnly =
false)
const;
1977 bool anchorAssetPathsOnly =
false)
const;
1981 size_t numTimeCodes)
const;
1999 std::is_same<T, VtArray<SdfAssetPath>>
::value ||
2001 std::is_same<T, VtArray<SdfTimeCode>>
::value ||
2037 bool _GetStrongestResolvedMetadata(
const UsdObject &obj,
2048 bool _GetTypeSpecificResolvedMetadata(
const UsdObject &obj,
2054 template <
class Composer>
2058 Composer *composer)
const;
2060 template <
class Composer>
2063 Composer *composer)
const;
2065 template <
class Composer>
2068 Composer *composer)
const;
2070 template <
class Composer>
2071 bool _GetSpecialPropMetadataImpl(
const UsdObject &obj,
2075 Composer *composer)
const;
2076 template <
class Composer>
2077 bool _GetMetadataImpl(
const UsdObject &obj,
2080 bool includeFallbacks,
2081 Composer *composer)
const;
2083 template <
class Composer>
2084 bool _GetGeneralMetadataImpl(
const UsdObject &obj,
2087 bool includeFallbacks,
2088 Composer *composer)
const;
2094 const TfToken &keyPath,
bool useFallbacks)
const;
2097 _ListMetadataFields(
const UsdObject &obj,
bool useFallbacks)
const;
2099 void _GetAllMetadata(
const UsdObject &obj,
2102 bool anchorAssetPathsOnly =
false)
const;
2112 void _GetResolveInfoWithResolveTarget(
2118 template <
class T>
struct _ExtraResolveInfo;
2129 _ExtraResolveInfo<T> *extraInfo =
nullptr)
const;
2138 void _GetResolveInfoWithResolveTarget(
2143 _ExtraResolveInfo<T> *extraInfo =
nullptr)
const;
2150 template <
class T,
class MakeUsdResolverFn>
2154 _ExtraResolveInfo<T> *extraInfo,
2155 const MakeUsdResolverFn &makeUsdResolveFn)
const;
2157 template <
class T>
struct _ResolveInfoResolver;
2158 struct _PropertyStackResolver;
2160 template <
class Resolver,
class MakeUsdResolverFn>
2161 void _GetResolvedValueAtDefaultImpl(
2164 const MakeUsdResolverFn &makeUsdResolverFn)
const;
2166 template <
class Resolver,
class MakeUsdResolverFn>
2167 void _GetResolvedValueAtTimeImpl(
2171 const MakeUsdResolverFn &makeUsdResolverFn)
const;
2182 Usd_InterpolatorBase* interpolator,
2199 Usd_InterpolatorBase* interpolator,
2203 bool _GetDefaultValueFromResolveInfoImpl(
const UsdResolveInfo &info,
2220 bool _GetTimeSamplesInInterval(
const UsdAttribute &attr,
2222 std::vector<double>* times)
const;
2224 bool _GetTimeSamplesInIntervalFromResolveInfo(
2228 std::vector<double>* times)
const;
2230 size_t _GetNumTimeSamples(
const UsdAttribute &attr)
const;
2232 size_t _GetNumTimeSamplesFromResolveInfo(
const UsdResolveInfo &info,
2238 bool _GetBracketingTimeSamples(
const UsdAttribute &attr,
2243 bool* hasSamples)
const;
2245 bool _GetBracketingTimeSamplesFromResolveInfo(
const UsdResolveInfo &info,
2251 bool* hasSamples)
const;
2253 bool _ValueMightBeTimeVarying(
const UsdAttribute &attr)
const;
2255 bool _ValueMightBeTimeVaryingFromResolveInfo(
const UsdResolveInfo &info,
2258 void _RegisterPerLayerNotices();
2259 void _RegisterResolverChangeNotice();
2262 inline char const *_GetMallocTagId()
const;
2278 bool _editTargetIsLocalLayer;
2280 std::unique_ptr<PcpCache> _cache;
2281 std::unique_ptr<Usd_ClipCache> _clipCache;
2282 std::unique_ptr<Usd_InstanceCache> _instanceCache;
2286 size_t _usedLayersRevision;
2293 inline size_t hash(
SdfPath const &path)
const {
2297 using PathToNodeMap = tbb::concurrent_hash_map<
2299 PathToNodeMap _primMap;
2304 typedef std::vector<
2305 std::pair<SdfLayerHandle, TfNotice::Key> > _LayerAndNoticeKeyVec;
2306 _LayerAndNoticeKeyVec _layersAndNoticeKeys;
2307 size_t _lastChangeSerialNumber;
2312 class _PendingChanges;
2313 _PendingChanges* _pendingChanges;
2315 hboost::optional<WorkDispatcher> _dispatcher;
2319 std::unique_ptr<std::string> _mallocTagID;
2330 bool _isClosingStage;
2331 bool _isWritingFallbackPrimTypes;
2352 template <
class RefsOrPayloadsEditorType,
class RefsOrPayloadsProxyType>
2362 UsdStage::_GetTypeSpecificResolvedMetadata(
const UsdObject &obj,
2368 template<
typename T>
2382 " match retrieved type %s",
2383 ArchGetDemangled<T>().c_str(),
2390 template<
typename T>
2398 template<
typename T>
2412 TF_CODING_ERROR(
"Requested type %s for stage metadatum %s[%s] does not"
2413 " match retrieved type %s",
2414 ArchGetDemangled<T>().c_str(),
2422 template<
typename T>
2433 typename std::enable_if<
2444 return _GetStrongestResolvedMetadata(
2445 obj, fieldName, keyPath, useFallbacks, &out);
2450 typename std::enable_if<
2452 UsdStage::_GetMetadata(
const UsdObject &obj,
2460 return _GetTypeSpecificResolvedMetadata(
2461 obj, fieldName, keyPath, useFallbacks, result);
2474 return _SetMetadataImpl<SdfAbstractDataConstValue>(
2475 object, key, keyPath, in);
2484 return _SetEditTargetMappedMetadata(
object, key, keyPath, value);
2489 #endif //PXR_USD_USD_STAGE_H
std::string upper(string_view a)
Return an all-upper case version of a (locale-independent).
USD_API void ExpandPopulationMask(std::function< bool(UsdRelationship const &)> const &relPred=nullptr, std::function< bool(UsdAttribute const &)> const &attrPred=nullptr)
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 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