Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
usd_utils.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
9
10#include <cctype>
11
12namespace momentum {
13
14std::string sanitizePrimName(const std::string& name) {
15 std::string result = name;
16 for (auto& c : result) {
17 if (!std::isalnum(static_cast<unsigned char>(c)) && c != '_') {
18 c = '_';
19 }
20 }
21 // Prim names must start with a letter or underscore, not a digit
22 if (!result.empty() && std::isdigit(static_cast<unsigned char>(result[0]))) {
23 result.insert(0, "_");
24 }
25 if (result.empty()) {
26 result = "_";
27 }
28 return result;
29}
30
31} // namespace momentum
std::string sanitizePrimName(const std::string &name)
Sanitize a string for use as a USD SDF prim name.
Definition usd_utils.cpp:14