24 #ifndef PXR_USD_USD_STAGE_H
25 #define PXR_USD_USD_STAGE_H
51 #include <hboost/optional.hpp>
53 #include <tbb/concurrent_vector.h>
54 #include <tbb/concurrent_unordered_set.h>
55 #include <tbb/spin_rw_mutex.h>
60 #include <unordered_map>
70 class Usd_InstanceCache;
71 class Usd_InstanceChanges;
72 class Usd_InterpolatorBase;
183 static UsdStageRefPtr
188 static UsdStageRefPtr
190 const SdfLayerHandle& sessionLayer,
194 static UsdStageRefPtr
196 const SdfLayerHandle& sessionLayer,
201 static UsdStageRefPtr
222 static UsdStageRefPtr
226 static UsdStageRefPtr
231 static UsdStageRefPtr
237 static UsdStageRefPtr
239 const SdfLayerHandle &sessionLayer,
243 static UsdStageRefPtr
245 const SdfLayerHandle &sessionLayer,
265 static UsdStageRefPtr
269 static UsdStageRefPtr
291 static UsdStageRefPtr
297 static UsdStageRefPtr
332 static UsdStageRefPtr
333 Open(
const SdfLayerHandle& rootLayer,
337 static UsdStageRefPtr
338 Open(
const SdfLayerHandle& rootLayer,
339 const SdfLayerHandle& sessionLayer,
343 static UsdStageRefPtr
344 Open(
const SdfLayerHandle& rootLayer,
349 static UsdStageRefPtr
350 Open(
const SdfLayerHandle& rootLayer,
351 const SdfLayerHandle& sessionLayer,
376 static UsdStageRefPtr
382 static UsdStageRefPtr
384 const SdfLayerHandle& sessionLayer,
389 static UsdStageRefPtr
396 static UsdStageRefPtr
398 const SdfLayerHandle& sessionLayer,
658 return _populationMask;
678 std::function<
bool (
UsdRelationship const &)>
const &relPred =
nullptr,
679 std::function<
bool (
UsdAttribute const &)>
const &attrPred =
nullptr);
824 _GetPrimDataAtPathOrInMaster(
const SdfPath &
path)
const;
827 std::vector<UsdPrim> _GetInstancesForMaster(
const UsdPrim& master)
const;
994 SdfLayerHandleVector
GetLayerStack(
bool includeSessionLayers=
true)
const;
1008 SdfLayerHandleVector
GetUsedLayers(
bool includeClipLayers=
true)
const;
1085 const std::vector<std::string> &unmuteLayers);
1120 bool addSourceFileComment=
true,
1133 bool addSourceFileComment=
true)
const;
1221 template<
typename T>
1253 template<
typename T>
1298 template<
typename T>
1531 TfToken *colorManagementSystem);
1549 const TfToken &colorManagementSystem);
1590 struct _IncludePayloadsPredicate;
1603 template <
class... Args>
1614 static UsdStageRefPtr
1625 SdfPropertySpecHandleVector
1628 SdfPropertySpecHandle
1629 _GetSchemaPropertySpec(
const UsdPrim &prim,
const TfToken &propName)
const;
1631 SdfPropertySpecHandle
1632 _GetSchemaPropertySpec(
const UsdProperty &prop)
const;
1634 template <
class PropType>
1636 _GetSchemaPropertySpec(
const UsdProperty &prop)
const;
1638 SdfAttributeSpecHandle
1639 _GetSchemaAttributeSpec(
const UsdAttribute &attr)
const;
1641 SdfRelationshipSpecHandle
1645 _CreatePrimSpecForEditing(
const UsdPrim& prim);
1647 template <
class PropType>
1649 _CreatePropertySpecForEditing(
const UsdProperty &prop);
1651 SdfPropertySpecHandle
1652 _CreatePropertySpecForEditing(
const UsdProperty &prop);
1654 SdfAttributeSpecHandle
1655 _CreateAttributeSpecForEditing(
const UsdAttribute &attr);
1657 SdfRelationshipSpecHandle
1663 std::pair<bool, UsdPrim>
1664 _IsValidPathForCreatingPrim(
const SdfPath &path)
const;
1669 bool _ValidateEditPrim(
const UsdPrim &prim,
const char* operation)
const;
1670 bool _ValidateEditPrimAtPath(
const SdfPath &primPath,
1671 const char* operation)
const;
1675 bool _RemoveProperty(
const SdfPath& path);
1689 struct _IsEditTargetMappable {
1690 static const bool value =
1692 std::is_same<T, VtArray<SdfTimeCode>>
::value ||
1715 bool _SetEditTargetMappedValue(
1739 bool _SetMetadata(
const UsdObject &
object,
1745 bool _SetEditTargetMappedMetadata(
1747 const TfToken &keyPath,
const T &newValue);
1750 bool _SetMetadataImpl(
1762 PcpCache const *_GetPcpCache()
const {
return _cache.get(); }
1763 PcpCache *_GetPcpCache() {
return _cache.get(); }
1774 const std::vector<std::string>& otherErrors,
1785 void _ComposePrimIndexesInParallel(
1786 const std::vector<SdfPath>& primIndexPaths,
1788 Usd_InstanceChanges* instanceChanges =
nullptr);
1792 void _ComposeSubtree(
1796 void _ComposeSubtreeImpl(
1801 void _ComposeSubtreesInParallel(
1802 const std::vector<Usd_PrimDataPtr> &prims,
1803 const std::vector<SdfPath> *primIndexPaths =
nullptr);
1839 void _DestroyPrimsInParallel(
const std::vector<SdfPath>&
paths);
1847 bool _IsObjectDescendantOfInstance(
const SdfPath& path)
const;
1854 SdfPath _GetPrimPathUsingPrimIndexAtPath(
const SdfPath& primIndexPath)
const;
1861 bool _RemovePrim(
const SdfPath& fullPath);
1863 SdfPrimSpecHandle _GetPrimSpec(
const SdfPath& fullPath);
1871 const TfToken &propName)
const;
1877 void _Recompose(
const PcpChanges &changes,
T *pathsToRecompose);
1879 void _RecomposePrims(
const PcpChanges &changes,
T *pathsToRecompose);
1885 template <
class Iter>
1886 void _ComputeSubtreesToRecompose(Iter
start, Iter finish,
1887 std::vector<Usd_PrimDataPtr>* recompose);
1891 bool _IsValidForLoad(
const SdfPath& path)
const;
1892 bool _IsValidForUnload(
const SdfPath& path)
const;
1902 void _DiscoverPayloads(
const SdfPath& rootPath,
1905 bool unloadedOnly =
false,
1930 size_t numAssetPaths,
1931 bool anchorAssetPathsOnly =
false)
const;
1935 bool anchorAssetPathsOnly =
false)
const;
1939 size_t numTimeCodes)
const;
1957 std::is_same<T, VtArray<SdfAssetPath>>
::value ||
1959 std::is_same<T, VtArray<SdfTimeCode>>
::value ||
1995 bool _GetStrongestResolvedMetadata(
const UsdObject &obj,
2006 bool _GetTypeSpecificResolvedMetadata(
const UsdObject &obj,
2012 template <
class Composer>
2016 Composer *composer)
const;
2018 template <
class Composer>
2021 Composer *composer)
const;
2023 template <
class Composer>
2026 Composer *composer)
const;
2028 template <
class Composer>
2029 bool _GetSpecialPropMetadataImpl(
const UsdObject &obj,
2033 Composer *composer)
const;
2034 template <
class Composer>
2035 bool _GetMetadataImpl(
const UsdObject &obj,
2038 bool includeFallbacks,
2039 Composer *composer)
const;
2041 template <
class Composer>
2042 bool _GetGeneralMetadataImpl(
const UsdObject &obj,
2045 bool includeFallbacks,
2046 Composer *composer)
const;
2052 const TfToken &keyPath,
bool useFallbacks)
const;
2055 _ListMetadataFields(
const UsdObject &obj,
bool useFallbacks)
const;
2057 void _GetAllMetadata(
const UsdObject &obj,
2060 bool anchorAssetPathsOnly =
false)
const;
2070 template <
class T>
struct _ExtraResolveInfo;
2076 _ExtraResolveInfo<T> *extraInfo =
nullptr)
const;
2078 template <
class T>
struct _ResolveInfoResolver;
2079 struct _PropertyStackResolver;
2081 template <
class Resolver>
2082 void _GetResolvedValueImpl(
const UsdProperty &prop,
2095 Usd_InterpolatorBase* interpolator,
2099 _GetLayerWithStrongestValue(
2118 Usd_InterpolatorBase* interpolator,
2131 bool _GetTimeSamplesInInterval(
const UsdAttribute &attr,
2133 std::vector<double>* times)
const;
2135 bool _GetTimeSamplesInIntervalFromResolveInfo(
2139 std::vector<double>* times)
const;
2141 size_t _GetNumTimeSamples(
const UsdAttribute &attr)
const;
2143 size_t _GetNumTimeSamplesFromResolveInfo(
const UsdResolveInfo &info,
2149 bool _GetBracketingTimeSamples(
const UsdAttribute &attr,
2154 bool* hasSamples)
const;
2156 bool _GetBracketingTimeSamplesFromResolveInfo(
const UsdResolveInfo &info,
2162 bool* hasSamples)
const;
2164 bool _ValueMightBeTimeVarying(
const UsdAttribute &attr)
const;
2166 bool _ValueMightBeTimeVaryingFromResolveInfo(
const UsdResolveInfo &info,
2169 void _RegisterPerLayerNotices();
2186 std::unique_ptr<PcpCache> _cache;
2187 std::unique_ptr<Usd_ClipCache> _clipCache;
2188 std::unique_ptr<Usd_InstanceCache> _instanceCache;
2196 mutable hboost::optional<tbb::spin_rw_mutex> _primMapMutex;
2201 typedef std::vector<
2202 std::pair<SdfLayerHandle, TfNotice::Key> > _LayerAndNoticeKeyVec;
2203 _LayerAndNoticeKeyVec _layersAndNoticeKeys;
2204 size_t _lastChangeSerialNumber;
2206 hboost::optional<WorkArenaDispatcher> _dispatcher;
2210 char const *_mallocTagID;
2221 bool _isClosingStage;
2222 bool _isWritingFallbackPrimTypes;
2242 template <
class RefsOrPayloadsEditorType,
class RefsOrPayloadsProxyType>
2252 UsdStage::_GetTypeSpecificResolvedMetadata(
const UsdObject &obj,
2258 template<
typename T>
2272 " match retrieved type %s",
2273 ArchGetDemangled<T>().c_str(),
2280 template<
typename T>
2288 template<
typename T>
2302 TF_CODING_ERROR(
"Requested type %s for stage metadatum %s[%s] does not"
2303 " match retrieved type %s",
2304 ArchGetDemangled<T>().c_str(),
2312 template<
typename T>
2323 typename std::enable_if<
2334 return _GetStrongestResolvedMetadata(
2335 obj, fieldName, keyPath, useFallbacks, &out);
2340 typename std::enable_if<
2342 UsdStage::_GetMetadata(
const UsdObject &obj,
2350 return _GetTypeSpecificResolvedMetadata(
2351 obj, fieldName, keyPath, useFallbacks, result);
2364 return _SetMetadataImpl<SdfAbstractDataConstValue>(
2374 return _SetEditTargetMappedMetadata(
object, key, keyPath, value);
2380 #endif //PXR_USD_USD_STAGE_H
T const & UncheckedGet() const
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
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 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
USD_API std::vector< UsdPrim > GetMasters() const
Returns all master prims.
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
SDF_DECLARE_HANDLES(SdfLayer)
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())
Load a prim plus all its descendants.
USD_API bool IsLayerMuted(const std::string &layerIdentifier) const
USD_API void SetDefaultPrim(const UsdPrim &prim)
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)
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.
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
std::map< class TfToken, VtValue, TfDictionaryLessThan > UsdMetadataValueMap
bool GetMetadataByDictKey(const TfToken &key, const TfToken &keyPath, T *value) const
USD_API UsdEditTarget GetEditTargetForLocalLayer(size_t i)
GLenum GLint GLint GLint GLint GLuint dstName
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
std::vector< PcpErrorBasePtr > PcpErrorVector
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
GLuint GLuint GLsizei GLenum type
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)
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.
GLsizei const GLchar *const * path
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)
GLsizei const GLchar *const * string
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.
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)
GLint GLboolean GLint layer
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
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
GLsizei const GLfloat * value
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
USD_API SdfLayerHandleVector GetUsedLayers(bool includeClipLayers=true) const
USD_API UsdAttribute GetAttributeAtPath(const SdfPath &path) const
GLenum const void * paths