24 #ifndef PXR_USD_USD_STAGE_H
25 #define PXR_USD_USD_STAGE_H
53 #include <hboost/optional.hpp>
55 #include <tbb/concurrent_vector.h>
56 #include <tbb/concurrent_unordered_set.h>
57 #include <tbb/spin_rw_mutex.h>
62 #include <unordered_map>
72 class Usd_InstanceCache;
73 class Usd_InstanceChanges;
74 class Usd_InterpolatorBase;
187 static UsdStageRefPtr
192 static UsdStageRefPtr
194 const SdfLayerHandle& sessionLayer,
198 static UsdStageRefPtr
200 const SdfLayerHandle& sessionLayer,
205 static UsdStageRefPtr
228 static UsdStageRefPtr
232 static UsdStageRefPtr
237 static UsdStageRefPtr
243 static UsdStageRefPtr
245 const SdfLayerHandle &sessionLayer,
249 static UsdStageRefPtr
251 const SdfLayerHandle &sessionLayer,
271 static UsdStageRefPtr
275 static UsdStageRefPtr
298 static UsdStageRefPtr
304 static UsdStageRefPtr
339 static UsdStageRefPtr
340 Open(
const SdfLayerHandle& rootLayer,
344 static UsdStageRefPtr
345 Open(
const SdfLayerHandle& rootLayer,
346 const SdfLayerHandle& sessionLayer,
350 static UsdStageRefPtr
351 Open(
const SdfLayerHandle& rootLayer,
356 static UsdStageRefPtr
357 Open(
const SdfLayerHandle& rootLayer,
358 const SdfLayerHandle& sessionLayer,
383 static UsdStageRefPtr
389 static UsdStageRefPtr
391 const SdfLayerHandle& sessionLayer,
396 static UsdStageRefPtr
403 static UsdStageRefPtr
405 const SdfLayerHandle& sessionLayer,
665 return _populationMask;
685 std::function<
bool (
UsdRelationship const &)>
const &relPred =
nullptr,
686 std::function<
bool (
UsdAttribute const &)>
const &attrPred =
nullptr);
832 _GetPrimDataAtPathOrInPrototype(
const SdfPath &
path)
const;
836 _GetInstancesForPrototype(
const UsdPrim& prototype)
const;
1003 SdfLayerHandleVector
GetLayerStack(
bool includeSessionLayers=
true)
const;
1017 SdfLayerHandleVector
GetUsedLayers(
bool includeClipLayers=
true)
const;
1101 const std::vector<std::string> &unmuteLayers);
1136 bool addSourceFileComment=
true,
1149 bool addSourceFileComment=
true)
const;
1237 template<
typename T>
1269 template<
typename T>
1314 template<
typename T>
1547 TfToken *colorManagementSystem);
1565 const TfToken &colorManagementSystem);
1606 struct _IncludePayloadsPredicate;
1619 template <
class... Args>
1630 static UsdStageRefPtr
1641 SdfPropertySpecHandleVector
1644 SdfPropertySpecHandle
1645 _GetSchemaPropertySpec(
const UsdPrim &prim,
const TfToken &propName)
const;
1647 SdfPropertySpecHandle
1648 _GetSchemaPropertySpec(
const UsdProperty &prop)
const;
1650 template <
class PropType>
1652 _GetSchemaPropertySpec(
const UsdProperty &prop)
const;
1654 SdfAttributeSpecHandle
1655 _GetSchemaAttributeSpec(
const UsdAttribute &attr)
const;
1657 SdfRelationshipSpecHandle
1661 _CreatePrimSpecForEditing(
const UsdPrim& prim);
1663 template <
class PropType>
1665 _CreatePropertySpecForEditing(
const UsdProperty &prop);
1667 SdfPropertySpecHandle
1668 _CreatePropertySpecForEditing(
const UsdProperty &prop);
1670 SdfAttributeSpecHandle
1671 _CreateAttributeSpecForEditing(
const UsdAttribute &attr);
1673 SdfRelationshipSpecHandle
1679 std::pair<bool, UsdPrim>
1680 _IsValidPathForCreatingPrim(
const SdfPath &path)
const;
1685 bool _ValidateEditPrim(
const UsdPrim &prim,
const char* operation)
const;
1686 bool _ValidateEditPrimAtPath(
const SdfPath &primPath,
1687 const char* operation)
const;
1691 bool _RemoveProperty(
const SdfPath& path);
1705 struct _IsEditTargetMappable {
1706 static const bool value =
1708 std::is_same<T, VtArray<SdfTimeCode>>
::value ||
1731 bool _SetEditTargetMappedValue(
1755 bool _SetMetadata(
const UsdObject &
object,
1761 bool _SetEditTargetMappedMetadata(
1763 const TfToken &keyPath,
const T &newValue);
1766 bool _SetMetadataImpl(
1778 PcpCache const *_GetPcpCache()
const {
return _cache.get(); }
1779 PcpCache *_GetPcpCache() {
return _cache.get(); }
1790 const std::vector<std::string>& otherErrors,
1801 void _ComposePrimIndexesInParallel(
1802 const std::vector<SdfPath>& primIndexPaths,
1804 Usd_InstanceChanges* instanceChanges =
nullptr);
1808 void _ComposeSubtree(
1812 void _ComposeSubtreeImpl(
1816 void _ComposeSubtreesInParallel(
1817 const std::vector<Usd_PrimDataPtr> &prims,
1818 const std::vector<SdfPath> *primIndexPaths =
nullptr);
1854 void _DestroyPrimsInParallel(
const std::vector<SdfPath>&
paths);
1862 bool _IsObjectDescendantOfInstance(
const SdfPath& path)
const;
1869 SdfPath _GetPrimPathUsingPrimIndexAtPath(
const SdfPath& primIndexPath)
const;
1879 void _ProcessPendingChanges();
1883 bool _RemovePrim(
const SdfPath& fullPath);
1885 SdfPrimSpecHandle _GetPrimSpec(
const SdfPath& fullPath);
1893 const TfToken &propName)
const;
1899 void _Recompose(
const PcpChanges &changes,
T *pathsToRecompose);
1901 void _RecomposePrims(
T *pathsToRecompose);
1907 template <
class Iter>
1908 void _ComputeSubtreesToRecompose(Iter
start, Iter finish,
1909 std::vector<Usd_PrimDataPtr>* recompose);
1913 bool _IsValidForLoad(
const SdfPath& path)
const;
1914 bool _IsValidForUnload(
const SdfPath& path)
const;
1924 void _DiscoverPayloads(
const SdfPath& rootPath,
1927 bool unloadedOnly =
false,
1952 size_t numAssetPaths,
1953 bool anchorAssetPathsOnly =
false)
const;
1957 bool anchorAssetPathsOnly =
false)
const;
1961 size_t numTimeCodes)
const;
1979 std::is_same<T, VtArray<SdfAssetPath>>
::value ||
1981 std::is_same<T, VtArray<SdfTimeCode>>
::value ||
2017 bool _GetStrongestResolvedMetadata(
const UsdObject &obj,
2028 bool _GetTypeSpecificResolvedMetadata(
const UsdObject &obj,
2034 template <
class Composer>
2038 Composer *composer)
const;
2040 template <
class Composer>
2043 Composer *composer)
const;
2045 template <
class Composer>
2048 Composer *composer)
const;
2050 template <
class Composer>
2051 bool _GetSpecialPropMetadataImpl(
const UsdObject &obj,
2055 Composer *composer)
const;
2056 template <
class Composer>
2057 bool _GetMetadataImpl(
const UsdObject &obj,
2060 bool includeFallbacks,
2061 Composer *composer)
const;
2063 template <
class Composer>
2064 bool _GetGeneralMetadataImpl(
const UsdObject &obj,
2067 bool includeFallbacks,
2068 Composer *composer)
const;
2074 const TfToken &keyPath,
bool useFallbacks)
const;
2077 _ListMetadataFields(
const UsdObject &obj,
bool useFallbacks)
const;
2079 void _GetAllMetadata(
const UsdObject &obj,
2082 bool anchorAssetPathsOnly =
false)
const;
2092 template <
class T>
struct _ExtraResolveInfo;
2098 _ExtraResolveInfo<T> *extraInfo =
nullptr)
const;
2100 template <
class T>
struct _ResolveInfoResolver;
2101 struct _PropertyStackResolver;
2103 template <
class Resolver>
2104 void _GetResolvedValueImpl(
const UsdProperty &prop,
2117 Usd_InterpolatorBase* interpolator,
2121 _GetLayerWithStrongestValue(
2140 Usd_InterpolatorBase* interpolator,
2153 bool _GetTimeSamplesInInterval(
const UsdAttribute &attr,
2155 std::vector<double>* times)
const;
2157 bool _GetTimeSamplesInIntervalFromResolveInfo(
2161 std::vector<double>* times)
const;
2163 size_t _GetNumTimeSamples(
const UsdAttribute &attr)
const;
2165 size_t _GetNumTimeSamplesFromResolveInfo(
const UsdResolveInfo &info,
2171 bool _GetBracketingTimeSamples(
const UsdAttribute &attr,
2176 bool* hasSamples)
const;
2178 bool _GetBracketingTimeSamplesFromResolveInfo(
const UsdResolveInfo &info,
2184 bool* hasSamples)
const;
2186 bool _ValueMightBeTimeVarying(
const UsdAttribute &attr)
const;
2188 bool _ValueMightBeTimeVaryingFromResolveInfo(
const UsdResolveInfo &info,
2191 void _RegisterPerLayerNotices();
2192 void _RegisterResolverChangeNotice();
2208 bool _editTargetIsLocalLayer;
2210 std::unique_ptr<PcpCache> _cache;
2211 std::unique_ptr<Usd_ClipCache> _clipCache;
2212 std::unique_ptr<Usd_InstanceCache> _instanceCache;
2216 size_t _usedLayersRevision;
2222 mutable hboost::optional<tbb::spin_rw_mutex> _primMapMutex;
2227 typedef std::vector<
2228 std::pair<SdfLayerHandle, TfNotice::Key> > _LayerAndNoticeKeyVec;
2229 _LayerAndNoticeKeyVec _layersAndNoticeKeys;
2230 size_t _lastChangeSerialNumber;
2235 class _PendingChanges;
2236 _PendingChanges* _pendingChanges;
2238 hboost::optional<WorkDispatcher> _dispatcher;
2242 char const *_mallocTagID;
2253 bool _isClosingStage;
2254 bool _isWritingFallbackPrimTypes;
2274 template <
class RefsOrPayloadsEditorType,
class RefsOrPayloadsProxyType>
2284 UsdStage::_GetTypeSpecificResolvedMetadata(
const UsdObject &obj,
2290 template<
typename T>
2304 " match retrieved type %s",
2305 ArchGetDemangled<T>().c_str(),
2312 template<
typename T>
2320 template<
typename T>
2334 TF_CODING_ERROR(
"Requested type %s for stage metadatum %s[%s] does not"
2335 " match retrieved type %s",
2336 ArchGetDemangled<T>().c_str(),
2344 template<
typename T>
2355 typename std::enable_if<
2366 return _GetStrongestResolvedMetadata(
2367 obj, fieldName, keyPath, useFallbacks, &out);
2372 typename std::enable_if<
2374 UsdStage::_GetMetadata(
const UsdObject &obj,
2382 return _GetTypeSpecificResolvedMetadata(
2383 obj, fieldName, keyPath, useFallbacks, result);
2396 return _SetMetadataImpl<SdfAbstractDataConstValue>(
2406 return _SetEditTargetMappedMetadata(
object, key, keyPath, value);
2412 #endif //PXR_USD_USD_STAGE_H
T const & UncheckedGet() const
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
USD_API void SetInterpolationType(UsdInterpolationType interpolationType)
GLenum GLuint GLint GLint layer
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
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())
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)
USD_API SdfLayerHandleVector GetLayerStack(bool includeSessionLayers=true) const
USD_API void LoadAndUnload(const SdfPathSet &loadSet, const SdfPathSet &unloadSet, UsdLoadPolicy policy=UsdLoadWithDescendants)
GLsizei const GLchar *const * string
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
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
GLsizei const GLfloat * value
**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.
GLenum GLint GLint GLint GLint GLuint dstName
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
USD_API SdfLayerHandleVector GetUsedLayers(bool includeClipLayers=true) const
GLenum const void * paths
USD_API UsdAttribute GetAttributeAtPath(const SdfPath &path) const