diff --git a/dart/common/Uri.cpp b/dart/common/Uri.cpp index 0f3e7bbbc0e81..9c2ddc36b8ad0 100644 --- a/dart/common/Uri.cpp +++ b/dart/common/Uri.cpp @@ -502,6 +502,23 @@ Uri Uri::createFromRelativeUri(const std::string& _base, return mergedUri; } +//============================================================================== +Uri Uri::createFromRelativeUri(const Uri& _base, + const std::string& _relative, bool _strict) +{ + Uri mergedUri; + if(!mergedUri.fromRelativeUri(_base, _relative, _strict)) + { + dtwarn << "[Uri::createFromRelativeUri] Failed merging URI '" << _relative + << "' with base URI '" << _base.toString() << "'.\n"; + } + + // We don't need to clear mergedUri since fromRelativeUri() does not set any + // component on failure. + + return mergedUri; +} + //============================================================================== Uri Uri::createFromRelativeUri(const Uri& _baseUri, const Uri& _relativeUri, bool _strict) @@ -541,6 +558,17 @@ std::string Uri::getRelativeUri( return mergedUri.toString(); } +//============================================================================== +std::string Uri::getRelativeUri( + const Uri& _base, const std::string& _relative, bool _strict) +{ + Uri mergedUri; + if(!mergedUri.fromRelativeUri(_base, _relative, _strict)) + return ""; + else + return mergedUri.toString(); +} + //============================================================================== std::string Uri::getRelativeUri( const Uri& _baseUri, const Uri& _relativeUri, bool _strict) diff --git a/dart/common/Uri.h b/dart/common/Uri.h index 9e2b912ad1478..62b0b814c3121 100644 --- a/dart/common/Uri.h +++ b/dart/common/Uri.h @@ -181,6 +181,12 @@ struct Uri final const std::string& _relative, bool _strict = false); + /// Create URI resolving a relative path reference; return an empty URI on + /// failure. + static Uri createFromRelativeUri(const Uri& _base, + const std::string& _relative, + bool _strict = false); + /// Create URI resolving a relative path reference; return an empty URI on /// failure. static Uri createFromRelativeUri(const Uri& _base, @@ -195,6 +201,11 @@ struct Uri final const std::string& _relative, bool _strict = false); + /// Resolve a relative path reference; return an empty string on failure. + static std::string getRelativeUri(const Uri& _base, + const std::string& _relative, + bool _strict = false); + /// Resolve a relative path reference; return an empty string on failure. static std::string getRelativeUri(const Uri& _base, const Uri& _relative, diff --git a/data/obj/Body_Hip.obj b/data/obj/Body_Hip.obj index a8c439c3e1a49..4162b135cc0e9 100644 --- a/data/obj/Body_Hip.obj +++ b/data/obj/Body_Hip.obj @@ -1,6 +1,5 @@ # Blender3D v249 OBJ File: # www.blender3d.org -mtllib Body_Hip.mtl v 0.000000 0.000000 0.000000 v 0.017500 -0.009750 -0.136500 v -0.009700 -0.009750 -0.136500 @@ -10676,7 +10675,6 @@ v -0.088194 -0.004910 0.060807 v -0.088854 -0.005907 0.059665 v -0.089512 -0.006906 0.058525 v -0.088594 -0.007304 0.058072 -usemtl Material.001 s 1 f 3 5 2 f 2 5 9 diff --git a/data/obj/BoxSmall.obj b/data/obj/BoxSmall.obj index 360079132622a..0e35fbe5bcd1a 100644 --- a/data/obj/BoxSmall.obj +++ b/data/obj/BoxSmall.obj @@ -1,6 +1,5 @@ # Blender3D v249 OBJ File: # www.blender3d.org -mtllib BoxSmall.mtl v 0.02000 -0.02000 -0.02000 v 0.02000 -0.02000 0.02000 v -0.02000 -0.02000 0.02000 @@ -9,7 +8,6 @@ v 0.02000 0.02000 -0.02000 v 0.02000 0.02000 0.02000 v -0.02000 0.02000 0.02000 v -0.02000 0.02000 -0.02000 -usemtl Material s off f 5 1 4 f 5 4 8 diff --git a/data/obj/foot.obj b/data/obj/foot.obj index fe8892ecb6dac..662506cdd3af5 100644 --- a/data/obj/foot.obj +++ b/data/obj/foot.obj @@ -1,6 +1,5 @@ # Blender3D v249 OBJ File: # www.blender3d.org -mtllib Body_LAR.mtl v 0.069500 -0.094390 -0.067470 v 0.069500 -0.094480 -0.067200 v 0.069490 -0.094480 -0.067260 @@ -5070,7 +5069,6 @@ v 0.069040 -0.094480 -0.070000 v 0.068930 -0.094480 -0.069720 v 0.068770 -0.094480 -0.069470 v 0.068560 -0.094480 -0.069260 -usemtl Material_001 s off f 28 1 29 f 29 1 2