Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed usd2sdf when import from model:// #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/sdf_parser/Geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,36 @@
fullName =
ignition::common::findFile(uri.Str());
}
else if (uri.Scheme() == "model")
{
fullName =
ignition::common::findFile(_geometry.MeshShape()->Uri());

Check warning on line 217 in src/sdf_parser/Geometry.cc

View check run for this annotation

Codecov / codecov/patch

src/sdf_parser/Geometry.cc#L217

Added line #L217 was not covered by tests

std::function<void(const std::string)> addSubFolders =
[&](const std::string &_dir)

Check warning on line 220 in src/sdf_parser/Geometry.cc

View check run for this annotation

Codecov / codecov/patch

src/sdf_parser/Geometry.cc#L220

Added line #L220 was not covered by tests
{
for (ignition::common::DirIter file(_dir);
file != ignition::common::DirIter(); ++file)

Check warning on line 223 in src/sdf_parser/Geometry.cc

View check run for this annotation

Codecov / codecov/patch

src/sdf_parser/Geometry.cc#L222-L223

Added lines #L222 - L223 were not covered by tests
{
std::string current(*file);
if (ignition::common::isDirectory(current))

Check warning on line 226 in src/sdf_parser/Geometry.cc

View check run for this annotation

Codecov / codecov/patch

src/sdf_parser/Geometry.cc#L225-L226

Added lines #L225 - L226 were not covered by tests
{
auto systemPaths = ignition::common::systemPaths();
systemPaths->AddFilePaths(current);
addSubFolders(current);

Check warning on line 230 in src/sdf_parser/Geometry.cc

View check run for this annotation

Codecov / codecov/patch

src/sdf_parser/Geometry.cc#L228-L230

Added lines #L228 - L230 were not covered by tests
}
}
};
auto fileExtensionIndex = fullName.rfind(
ignition::common::basename(fullName));
if (fileExtensionIndex != std::string::npos)

Check warning on line 236 in src/sdf_parser/Geometry.cc

View check run for this annotation

Codecov / codecov/patch

src/sdf_parser/Geometry.cc#L233-L236

Added lines #L233 - L236 were not covered by tests
{
std::string dirName = fullName;

Check warning on line 238 in src/sdf_parser/Geometry.cc

View check run for this annotation

Codecov / codecov/patch

src/sdf_parser/Geometry.cc#L238

Added line #L238 was not covered by tests
dirName.erase(fileExtensionIndex,
ignition::common::basename(fullName).length() + 1);
addSubFolders(ignition::common::parentPath(dirName));

Check warning on line 241 in src/sdf_parser/Geometry.cc

View check run for this annotation

Codecov / codecov/patch

src/sdf_parser/Geometry.cc#L240-L241

Added lines #L240 - L241 were not covered by tests
}
}
else
{
fullName =
Expand Down