HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
udimUtils.h
Go to the documentation of this file.
1 //
2 // Copyright 2023 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_SHADE_UDIM_UTILS_H
8 #define PXR_USD_USD_SHADE_UDIM_UTILS_H
9 
10 #include "pxr/pxr.h"
12 #include "pxr/usd/usdShade/api.h"
13 
14 #include <string>
15 #include <utility>
16 #include <vector>
17 
19 
21 
22 /// \class UsdShadeUdimUtils
23 ///
24 /// This class contains a set of utility functions used for working with Udim
25 /// texture paths
26 ///
28 public:
29 
30  /// Pair representing a resolved UDIM path.
31  /// The first member is the fully resolved path
32  /// The second number contains only the UDIM tile identifier.
33  using ResolvedPathAndTile = std::pair<std::string, std::string>;
34 
35  /// Checks if \p identifier contains a UDIM token. Currently only "<UDIM>"
36  /// is supported, but other patterns such as "_MAPID_" may be supported in
37  /// the future.
39  static bool IsUdimIdentifier(const std::string &identifier);
40 
41  /// Replaces the UDIM pattern contained in \p identifierWithPattern
42  /// with \p replacement
44  static std::string ReplaceUdimPattern(
45  const std::string &identifierWithPattern,
46  const std::string &replacement);
47 
48  /// Resolves a \p udimPath containing a UDIM token. The path is first
49  /// anchored with the passed \p layer if needed, then the function attempts
50  /// to resolve any possible UDIM tiles. If any exist, the resolved path is
51  /// returned with "<UDIM>" substituted back in. If no resolves succeed or
52  /// \p udimPath does not contain a UDIM token, an empty string is returned.
54  static std::string ResolveUdimPath(
55  const std::string &udimPath,
56  const SdfLayerHandle &layer);
57 
58  /// Attempts to resolve all paths which match a path containing a UDIM
59  /// pattern. The path is first anchored with the passed \p layer if needed,
60  /// then the function attempts to resolve all possible UDIM numbers in the
61  /// path.
63  static std::vector<ResolvedPathAndTile> ResolveUdimTilePaths(
64  const std::string &udimPath,
65  const SdfLayerHandle &layer);
66 };
67 
69 
70 #endif
#define USDSHADE_API
Definition: api.h:23
Definition: layer.h:81
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1299
static USDSHADE_API std::string ReplaceUdimPattern(const std::string &identifierWithPattern, const std::string &replacement)
static USDSHADE_API bool IsUdimIdentifier(const std::string &identifier)
PXR_NAMESPACE_OPEN_SCOPE SDF_DECLARE_HANDLES(SdfLayer)
std::pair< std::string, std::string > ResolvedPathAndTile
Definition: udimUtils.h:33
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
static USDSHADE_API std::vector< ResolvedPathAndTile > ResolveUdimTilePaths(const std::string &udimPath, const SdfLayerHandle &layer)
static USDSHADE_API std::string ResolveUdimPath(const std::string &udimPath, const SdfLayerHandle &layer)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74