HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stitchClips.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_STITCH_CLIPS_H
8 #define PXR_USD_USD_UTILS_STITCH_CLIPS_H
9 
10 /// \file usdUtils/stitchClips.h
11 ///
12 /// Collection of utilities for sequencing multiple layers each holding
13 /// sequential time-varying data into
14 /// \ref Usd_Page_ValueClips "USD Value Clips".
15 
16 #include "pxr/pxr.h"
17 #include "pxr/usd/usdUtils/api.h"
18 #include "pxr/usd/usd/clipsAPI.h"
20 #include "pxr/usd/sdf/path.h"
21 
22 #include <limits>
23 
25 
27 
28 /// A function that creates layers that use
29 /// \ref Usd_Page_ValueClips "USD Value Clips"
30 /// to effectively merge the time samples in the given \p clipLayers under \p
31 /// clipPath without copying the samples into a separate layer.
32 ///
33 /// \p resultLayer The layer to which clip metadata and frame data
34 /// will be written. The layer representing the static
35 /// scene topology will be authored as a sublayer on
36 /// this layer as well; it will be authored as the
37 /// first sublayer in the list(strongest).
38 ///
39 /// \p clipLayerFiles The files containing the time varying data.
40 ///
41 /// \p clipPath The path at which we will put the clip metadata.
42 ///
43 /// \p startTimeCode The first time coordinate for the rootLayer
44 /// to point to. If none is provided, it will be
45 /// the lowest startTimeCode available from
46 /// the \p clipLayers.
47 ///
48 /// \p endTimeCode The last time coordinate for the rootLayer to
49 /// point to. If none is provided, it will be the
50 /// highest endTimeCode authored from the
51 /// \p clipLayers.
52 ///
53 /// \p interpolateMissingClipValues
54 /// Whether values for clips without samples are
55 /// interpolated from surrounding clips. See
56 /// UsdClipsAPI::GetInterpolateMissingClipValues
57 /// for more details.
58 ///
59 /// \p clipSet The name of the clipSet in which the
60 /// aforementioned metadata will be authored.
61 /// \note If this parameter is omitted, the default
62 /// clipSet name will be authored.
63 ///
64 /// Details on how this is accomplished can be found below:
65 ///
66 /// Pre-existing opinions will be wiped away upon success. Upon failure, the
67 /// original topology and manifest layers, if pre-existing, will be preserved.
68 /// These layers will be named/looked up via the following scheme:
69 ///
70 /// topologyLayerName = <resultIdWithoutExt>.topology.<resultExt>
71 /// manifestLayerName = <resultIdWithoutExt>.manifest.<resultExt>
72 ///
73 /// For example: if the resultLayerFile's name is foo.usd the expected topology
74 /// layer will be foo.topology.usd and the expected manifest layer will be
75 /// foo.manifest.usd.
76 ///
77 /// The topology layer contains the aggregated topology of the set of
78 /// \p clipLayers. This process will merge prims and properties, save for time
79 /// varying properties, those will be accessed from the original
80 /// clip files.
81 ///
82 /// The aggregation of topology works by merging a clipLayer at a time with
83 /// the topologyLayer. If a prim already exists in the topologyLayer, its
84 /// attributes will be merged.
85 ///
86 /// For example, if we have a layer, clipA with attributes /World/fx/foo.bar
87 /// and a second layer with /World/fx/foo.baz. Our aggregate topology layer
88 /// will contain both /World/fx/foo.bar, /World/fx/foo.baz.
89 ///
90 /// The manifest layer contains declarations for all attributes that exist
91 /// under \p clipPath and descendants in the clip layers with authored time
92 /// samples. Any default values authored into the topology layer for these
93 /// time sampled attributes will also be authored into the manifest.
94 ///
95 /// The \p resultLayer will contain clip metadata at the specified \p clipPath.
96 /// The resultLayer will also have timeCode range data, such as start and end
97 /// timeCodes written to it, with the starting position being provided by
98 /// \p startTimeCode and the ending provided by \p endTimeCode.
99 ///
100 /// Note: an invalid clip path(because the prim doesn't exist in
101 /// the aggregate topologyLayer) will result in a TF_CODING_ERROR.
102 ///
104 bool
105 UsdUtilsStitchClips(const SdfLayerHandle& resultLayer,
106  const std::vector<std::string>& clipLayerFiles,
107  const SdfPath& clipPath,
108  const double startTimeCode
110  const double endTimeCode
112  const bool interpolateMissingClipValues
113  = false,
114  const TfToken& clipSet
115  = UsdClipsAPISetNames->default_);
116 
117 /// A function which aggregates the topology of a set of \p clipLayerFiles
118 /// for use in USD's Value Clips system. This aggregated scene topology
119 /// will only include non-time-varying data, as it is for use in conjunction
120 /// with the value clip metadata in a manifest layer.
121 ///
122 /// \p topologyLayer The layer in which topology of the
123 /// \p clipLayerFiles will be aggregated and inserted.
124 ///
125 /// \p clipLayerFiles The files containing the time varying data.
126 ///
128 bool
129 UsdUtilsStitchClipsTopology(const SdfLayerHandle& topologyLayer,
130  const std::vector<std::string>& clipLayerFiles);
131 
132 /// A function which creates a clip manifest from the set of \p clipLayerFiles
133 /// for use in USD's Value Clips system. This manifest will contain
134 /// declarations for attributes with authored time samples in the clip layers.
135 /// If a time sampled attribute has a default value authored in the given
136 /// \p topologyLayer, that value will also be authored as its default in the
137 /// manifest.
138 ///
139 /// \p manifestLayer The layer where manifest data will be inserted.
140 ///
141 /// \p topologyLayer The topology layer for \p clipLayerFiles.
142 ///
143 /// \p clipLayerFiles The files containing the time varying data.
144 ///
145 /// \p clipPrimPath The manifest will contain attributes from this
146 /// prim and its descendants in \p clipLayerFiles.
148 bool
149 UsdUtilsStitchClipsManifest(const SdfLayerHandle& manifestLayer,
150  const SdfLayerHandle& topologyLayer,
151  const std::vector<std::string>& clipLayerFiles,
152  const SdfPath& clipPath);
153 
154 /// A function which authors clip template metadata on a particular prim in a
155 /// result layer, as well as adding the topologyLayer to the list of subLayers
156 /// on the \p resultLayer. It will clear the \p resultLayer and create
157 /// a prim at \p clipPath. Specifically, this will author clipPrimPath,
158 /// clipTemplateAssetPath, clipTemplateStride, clipTemplateStartTime,
159 /// clipTemplateEndTime, and clipManifestAssetPath.
160 ///
161 /// \p resultLayer The layer in which we will author the metadata.
162 ///
163 /// \p topologyLayer The layer containing the aggregate topology of
164 /// the clipLayers which the metadata refers to.
165 ///
166 /// \p manifestLayer The layer containing manifest for the attributes
167 /// in the clipLayers.
168 ///
169 /// \p clipPath The path at which to author the metadata in
170 /// \p resultLayer
171 ///
172 /// \p templatePath The template string to be authored at the
173 /// clipTemplateAssetPath metadata key.
174 ///
175 /// \p startTime The start time to be authored at the
176 /// clipTemplateStartTime metadata key.
177 ///
178 /// \p endTime The end time to be authored at the
179 /// clipTemplateEndTime metadata key.
180 ///
181 /// \p stride The stride to be authored at the
182 /// clipTemplateStride metadata key.
183 ///
184 /// \p activeOffset The offset to be authored at the
185 /// clipTemplateActiveOffset metadata key.
186 /// \note If this parameter is omitted, no value
187 /// will be authored as the metadata is optional.
188 ///
189 /// \p interpolateMissingClipValues
190 /// Whether values for clips without samples are
191 /// interpolated from surrounding clips. See
192 /// UsdClipsAPI::GetInterpolateMissingClipValues
193 /// for more details.
194 ///
195 /// \p clipSet The name of the clipSet in which the
196 /// aforementioned metadata will be authored.
197 /// \note If this parameter is omitted, the default
198 /// clipSet name("default") will be authored.
199 ///
200 /// For further information on these metadatum, see \ref Usd_Page_AdvancedFeatures
201 ///
203 bool
204 UsdUtilsStitchClipsTemplate(const SdfLayerHandle& resultLayer,
205  const SdfLayerHandle& topologyLayer,
206  const SdfLayerHandle& manifestLayer,
207  const SdfPath& clipPath,
208  const std::string& templatePath,
209  const double startTime,
210  const double endTime,
211  const double stride,
212  const double activeOffset
214  const bool interpolateMissingClipValues
215  = false,
216  const TfToken& clipSet
217  = UsdClipsAPISetNames->default_);
218 
219 /// Generates a topology file name based on an input file name
220 ///
221 /// For example, if given 'foo.usd', it generates 'foo.topology.usd'
222 ///
223 /// Note: this will not strip preceding paths off of a file name
224 /// so /bar/baz/foo.usd will produce /bar/baz/foo.topology.usd
225 ///
226 /// \p rootLayerName The filepath used as a basis for generating
227 /// our topology layer name.
229 std::string
230 UsdUtilsGenerateClipTopologyName(const std::string& rootLayerName);
231 
232 /// Generates a manifest file name based on an input file name
233 ///
234 /// For example, if given 'foo.usd', it generates 'foo.manifest.usd'
235 ///
236 /// Note: this will not strip preceding paths off of a file name
237 /// so /bar/baz/foo.usd will produce /bar/baz/foo.manifest.usd
238 ///
239 /// \p rootLayerName The filepath used as a basis for generating
240 /// our manifest layer name.
242 std::string
243 UsdUtilsGenerateClipManifestName(const std::string& rootLayerName);
244 
246 
247 #endif /* PXR_USD_USD_UTILS_STITCH_CLIPS_H */
USDUTILS_API bool UsdUtilsStitchClipsManifest(const SdfLayerHandle &manifestLayer, const SdfLayerHandle &topologyLayer, const std::vector< std::string > &clipLayerFiles, const SdfPath &clipPath)
USDUTILS_API bool UsdUtilsStitchClips(const SdfLayerHandle &resultLayer, const std::vector< std::string > &clipLayerFiles, const SdfPath &clipPath, const double startTimeCode=std::numeric_limits< double >::max(), const double endTimeCode=std::numeric_limits< double >::max(), const bool interpolateMissingClipValues=false, const TfToken &clipSet=UsdClipsAPISetNames->default_)
Definition: layer.h:81
USDUTILS_API bool UsdUtilsStitchClipsTopology(const SdfLayerHandle &topologyLayer, const std::vector< std::string > &clipLayerFiles)
Definition: token.h:70
USDUTILS_API std::string UsdUtilsGenerateClipTopologyName(const std::string &rootLayerName)
GLint GLenum GLboolean GLsizei stride
Definition: glcorearb.h:872
Definition: path.h:273
USDUTILS_API bool UsdUtilsStitchClipsTemplate(const SdfLayerHandle &resultLayer, const SdfLayerHandle &topologyLayer, const SdfLayerHandle &manifestLayer, const SdfPath &clipPath, const std::string &templatePath, const double startTime, const double endTime, const double stride, const double activeOffset=std::numeric_limits< double >::max(), const bool interpolateMissingClipValues=false, const TfToken &clipSet=UsdClipsAPISetNames->default_)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
PXR_NAMESPACE_OPEN_SCOPE SDF_DECLARE_HANDLES(SdfLayer)
#define USDUTILS_API
Definition: api.h:23
USDUTILS_API std::string UsdUtilsGenerateClipManifestName(const std::string &rootLayerName)