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 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_SHADE_UDIM_UTILS_H
25 #define PXR_USD_USD_SHADE_UDIM_UTILS_H
26 
27 #include "pxr/pxr.h"
29 #include "pxr/usd/usdShade/api.h"
30 
31 #include <string>
32 #include <utility>
33 #include <vector>
34 
36 
38 
39 /// \class UsdShadeUdimUtils
40 ///
41 /// This class contains a set of utility functions used for working with Udim
42 /// texture paths
43 ///
45 public:
46 
47  /// Pair representing a resolved UDIM path.
48  /// The first member is the fully resolved path
49  /// The second number contains only the UDIM tile identifier.
50  using ResolvedPathAndTile = std::pair<std::string, std::string>;
51 
52  /// Checks if \p identifier contains a UDIM token. Currently only "<UDIM>"
53  /// is supported, but other patterns such as "_MAPID_" may be supported in
54  /// the future.
56  static bool IsUdimIdentifier(const std::string &identifier);
57 
58  /// Replaces the UDIM pattern contained in \p identifierWithPattern
59  /// with \p replacement
62  const std::string &identifierWithPattern,
63  const std::string &replacement);
64 
65  /// Resolves a \p udimPath containing a UDIM token. The path is first
66  /// anchored with the passed \p layer if needed, then the function attempts
67  /// to resolve any possible UDIM tiles. If any exist, the resolved path is
68  /// returned with "<UDIM>" substituted back in. If no resolves succeed or
69  /// \p udimPath does not contain a UDIM token, an empty string is returned.
72  const std::string &udimPath,
73  const SdfLayerHandle &layer);
74 
75  /// Attempts to resolve all paths which match a path containing a UDIM
76  /// pattern. The path is first anchored with the passed \p layer if needed,
77  /// then the function attempts to resolve all possible UDIM numbers in the
78  /// path.
80  static std::vector<ResolvedPathAndTile> ResolveUdimTilePaths(
81  const std::string &udimPath,
82  const SdfLayerHandle &layer);
83 };
84 
86 
87 #endif
#define USDSHADE_API
Definition: api.h:40
Definition: layer.h:97
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
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:50
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
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:91