HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
introspection.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_USD_UTILS_INTROSPECTION_H
8 #define PXR_USD_USD_UTILS_INTROSPECTION_H
9 
10 /// \file usdUtils/introspection.h
11 ///
12 /// Collection of module-scoped utilities for introspecting a given USD stage.
13 /// Future additions might include full-on dependency extraction, queries like
14 /// "Does this stage contain this asset?", "usd grep" functionality, etc.
15 
16 #include "pxr/pxr.h"
17 #include "pxr/usd/usdUtils/api.h"
19 #include "pxr/usd/sdf/path.h"
20 
21 #include "pxr/usd/usd/stage.h"
22 
23 #include "pxr/base/tf/envSetting.h"
24 #include "pxr/base/vt/dictionary.h"
25 
27 
28 
30 
31 #define USDUTILS_USDSTAGE_STATS \
32  (approxMemoryInMb) \
33  (totalPrimCount) \
34  (modelCount) \
35  (instancedModelCount) \
36  (assetCount) \
37  (prototypeCount) \
38  (totalInstanceCount) \
39  (usedLayerCount) \
40  (primary) \
41  (prototypes) \
42  (primCounts) \
43  /*(totalPrimCount)*/ \
44  (activePrimCount) \
45  (inactivePrimCount) \
46  (pureOverCount) \
47  (instanceCount) \
48  (primCountsByType) \
49  (untyped)
50 
51 TF_DECLARE_PUBLIC_TOKENS(UsdUtilsUsdStageStatsKeys,
53 
54 /// Opens the given layer on a USD stage and collects various stats.
55 /// The stats are populated in the dictionary-valued output param \p stats.
56 ///
57 /// The set of stats include:
58 /// * approxMemoryInMb - approximate memory allocated when opening the stage
59 /// with all the models loaded.
60 /// * totalPrimCount - total number of prims
61 /// * modelCount - number of models
62 /// * instancedModelCount - number of instanced models
63 /// * assetCount - number of assets
64 /// * prototypeCount - number of prototypes
65 /// * totalInstanceCount - total number of instances (including nested instances)
66 /// * two sub-dictionaries, 'primary' and 'prototypes' for the "primary" prim tree
67 /// and for all the prototype subtrees respectively, containing the following
68 /// stats:
69 /// * primCounts - a sub-dictionary containing the following
70 /// * totalPrimCount - number of prims
71 /// * activePrimCount - number of active prims
72 /// * inactivePrimCount - number of inactive prims
73 /// * pureOverCount - number of pure overs
74 /// * instanceCount - number of instances
75 /// * primCountsByType - a sub-dictionary containing prim counts keyed by the
76 /// prim type.
77 ///
78 /// Returns the stage that was opened.
79 ///
80 /// The "prototypes" subdictionary is populated only if the stage has one or more
81 /// instanced models.
82 ///
83 /// \note The approximate memory allocated when opening the stage is computed
84 /// and reported *only* if the TfMallocTag system has already been initialized
85 /// by the client, and the number will represent only *additional* consumed
86 /// memory, so if some of the layers the stage uses are already open, the true
87 /// memory consumption for the stage may be higher than reported.
88 /// \sa TfMallocTag::IsInitialized()
89 ///
90 /// \note Only component models are included in 'modelCount' and
91 /// 'instancedModelCount'.
92 ///
94 UsdStageRefPtr UsdUtilsComputeUsdStageStats(const std::string &rootLayerPath,
95  VtDictionary *stats);
96 
97 /// \overload
98 /// Computes stats on an already opened USD stage.
99 ///
100 /// Returns the total number of prims on the stage, including active, inactive.
101 /// pure overs, prims inside prototypes etc.
102 ///
104 size_t UsdUtilsComputeUsdStageStats(const UsdStageWeakPtr &stage,
105  VtDictionary *stats);
106 
107 
109 
110 #endif /* PXR_USD_USD_UTILS_INTROSPECTION_H */
Definition: layer.h:81
TF_DECLARE_PUBLIC_TOKENS(UsdUtilsUsdStageStatsKeys, USDUTILS_API, USDUTILS_USDSTAGE_STATS)
UsdStagePtr UsdStageWeakPtr
Definition: common.h:38
USDUTILS_API UsdStageRefPtr UsdUtilsComputeUsdStageStats(const std::string &rootLayerPath, VtDictionary *stats)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define USDUTILS_USDSTAGE_STATS
Definition: introspection.h:31
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
#define USDUTILS_API
Definition: api.h:23
PXR_NAMESPACE_OPEN_SCOPE SDF_DECLARE_HANDLES(SdfLayer)