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 Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_USD_USD_UTILS_INTROSPECTION_H
25 #define PXR_USD_USD_UTILS_INTROSPECTION_H
26 
27 /// \file usdUtils/introspection.h
28 ///
29 /// Collection of module-scoped utilities for introspecting a given USD stage.
30 /// Future additions might include full-on dependency extraction, queries like
31 /// "Does this stage contain this asset?", "usd grep" functionality, etc.
32 
33 #include "pxr/pxr.h"
34 #include "pxr/usd/usdUtils/api.h"
36 #include "pxr/usd/sdf/path.h"
37 
38 #include "pxr/usd/usd/stage.h"
39 
40 #include "pxr/base/tf/envSetting.h"
41 #include "pxr/base/vt/dictionary.h"
42 
44 
45 
47 
48 #define USDUTILS_USDSTAGE_STATS \
49  (approxMemoryInMb) \
50  (totalPrimCount) \
51  (modelCount) \
52  (instancedModelCount) \
53  (assetCount) \
54  (prototypeCount) \
55  (totalInstanceCount) \
56  (usedLayerCount) \
57  (primary) \
58  (prototypes) \
59  (primCounts) \
60  /*(totalPrimCount)*/ \
61  (activePrimCount) \
62  (inactivePrimCount) \
63  (pureOverCount) \
64  (instanceCount) \
65  (primCountsByType) \
66  (untyped)
67 
68 TF_DECLARE_PUBLIC_TOKENS(UsdUtilsUsdStageStatsKeys,
70 
71 /// Opens the given layer on a USD stage and collects various stats.
72 /// The stats are populated in the dictionary-valued output param \p stats.
73 ///
74 /// The set of stats include:
75 /// * approxMemoryInMb - approximate memory allocated when opening the stage
76 /// with all the models loaded.
77 /// * totalPrimCount - total number of prims
78 /// * modelCount - number of models
79 /// * instancedModelCount - number of instanced models
80 /// * assetCount - number of assets
81 /// * prototypeCount - number of prototypes
82 /// * totalInstanceCount - total number of instances (including nested instances)
83 /// * two sub-dictionaries, 'primary' and 'prototypes' for the "primary" prim tree
84 /// and for all the prototype subtrees respectively, containing the following
85 /// stats:
86 /// * primCounts - a sub-dictionary containing the following
87 /// * totalPrimCount - number of prims
88 /// * activePrimCount - number of active prims
89 /// * inactivePrimCount - number of inactive prims
90 /// * pureOverCount - number of pure overs
91 /// * instanceCount - number of instances
92 /// * primCountsByType - a sub-dictionary containing prim counts keyed by the
93 /// prim type.
94 ///
95 /// Returns the stage that was opened.
96 ///
97 /// The "prototypes" subdictionary is populated only if the stage has one or more
98 /// instanced models.
99 ///
100 /// \note The approximate memory allocated when opening the stage is computed
101 /// and reported *only* if the TfMallocTag system has already been initialized
102 /// by the client, and the number will represent only *additional* consumed
103 /// memory, so if some of the layers the stage uses are already open, the true
104 /// memory consumption for the stage may be higher than reported.
105 /// \sa TfMallocTag::IsInitialized()
106 ///
107 /// \note Only component models are included in 'modelCount' and
108 /// 'instancedModelCount'.
109 ///
111 UsdStageRefPtr UsdUtilsComputeUsdStageStats(const std::string &rootLayerPath,
112  VtDictionary *stats);
113 
114 /// \overload
115 /// Computes stats on an already opened USD stage.
116 ///
117 /// Returns the total number of prims on the stage, including active, inactive.
118 /// pure overs, prims inside prototypes etc.
119 ///
121 size_t UsdUtilsComputeUsdStageStats(const UsdStageWeakPtr &stage,
122  VtDictionary *stats);
123 
124 
126 
127 #endif /* PXR_USD_USD_UTILS_INTROSPECTION_H */
Definition: layer.h:94
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
TF_DECLARE_PUBLIC_TOKENS(UsdUtilsUsdStageStatsKeys, USDUTILS_API, USDUTILS_USDSTAGE_STATS)
UsdStagePtr UsdStageWeakPtr
Definition: common.h:55
USDUTILS_API UsdStageRefPtr UsdUtilsComputeUsdStageStats(const std::string &rootLayerPath, VtDictionary *stats)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#define USDUTILS_USDSTAGE_STATS
Definition: introspection.h:48
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
#define USDUTILS_API
Definition: api.h:40
PXR_NAMESPACE_OPEN_SCOPE SDF_DECLARE_HANDLES(SdfLayer)