Skip to content

Commit 06fac16

Browse files
authored
Merge branch 'sdf13' into python_module_version
2 parents c07d59c + 707cb30 commit 06fac16

28 files changed

+769
-27
lines changed

include/sdf/Collision.hh

+10
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ namespace sdf
3434
//
3535
// Forward declaration.
3636
class Geometry;
37+
class ParserConfig;
3738
class Surface;
3839
struct PoseRelativeToGraph;
3940
template <typename T> class ScopedGraph;
@@ -55,6 +56,15 @@ namespace sdf
5556
/// an error code and message. An empty vector indicates no error.
5657
public: Errors Load(ElementPtr _sdf);
5758

59+
/// \brief Load the collision based on a element pointer. This is *not* the
60+
/// usual entry point. Typical usage of the SDF DOM is through the Root
61+
/// object.
62+
/// \param[in] _sdf The SDF Element pointer
63+
/// \param[in] _config Parser configuration
64+
/// \return Errors, which is a vector of Error objects. Each Error includes
65+
/// an error code and message. An empty vector indicates no error.
66+
public: Errors Load(sdf::ElementPtr _sdf, const ParserConfig &_config);
67+
5868
/// \brief Get the name of the collision.
5969
/// The name of the collision must be unique within the scope of a Link.
6070
/// \return Name of the collision.

include/sdf/Geometry.hh

+10
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ namespace sdf
3737
class Ellipsoid;
3838
class Heightmap;
3939
class Mesh;
40+
class ParserConfig;
4041
class Plane;
4142
class Polyline;
4243
class Sphere;
@@ -93,6 +94,15 @@ namespace sdf
9394
/// an error code and message. An empty vector indicates no error.
9495
public: Errors Load(ElementPtr _sdf);
9596

97+
/// \brief Load the geometry based on a element pointer. This is *not* the
98+
/// usual entry point. Typical usage of the SDF DOM is through the Root
99+
/// object.
100+
/// \param[in] _sdf The SDF Element pointer
101+
/// \param[in] _config Parser configuration
102+
/// \return Errors, which is a vector of Error objects. Each Error includes
103+
/// an error code and message. An empty vector indicates no error.
104+
public: Errors Load(sdf::ElementPtr _sdf, const ParserConfig &_config);
105+
96106
/// \brief Get the type of geometry.
97107
/// \return The geometry type.
98108
public: GeometryType Type() const;

include/sdf/Heightmap.hh

+23
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ namespace sdf
2828
{
2929
// Inline bracket to help doxygen filtering.
3030
inline namespace SDF_VERSION_NAMESPACE {
31+
//
32+
33+
// Forward declarations.
34+
class ParserConfig;
35+
3136
/// \brief Texture to be used on heightmaps.
3237
class SDFORMAT_VISIBLE HeightmapTexture
3338
{
@@ -42,6 +47,15 @@ namespace sdf
4247
/// an error code and message. An empty vector indicates no error.
4348
public: Errors Load(ElementPtr _sdf);
4449

50+
/// \brief Load the heightmap texture geometry based on a element pointer.
51+
/// This is *not* the usual entry point. Typical usage of the SDF DOM is
52+
/// through the Root object.
53+
/// \param[in] _sdf The SDF Element pointer
54+
/// \param[in] _config Parser configuration
55+
/// \return Errors, which is a vector of Error objects. Each Error includes
56+
/// an error code and message. An empty vector indicates no error.
57+
public: Errors Load(sdf::ElementPtr _sdf, const ParserConfig &_config);
58+
4559
/// \brief Get the heightmap texture's size.
4660
/// \return The size of the heightmap texture in meters.
4761
public: double Size() const;
@@ -129,6 +143,15 @@ namespace sdf
129143
/// an error code and message. An empty vector indicates no error.
130144
public: Errors Load(ElementPtr _sdf);
131145

146+
/// \brief Load the heightmap geometry based on a element pointer.
147+
/// This is *not* the usual entry point. Typical usage of the SDF DOM is
148+
/// through the Root object.
149+
/// \param[in] _sdf The SDF Element pointer
150+
/// \param[in] _config Parser configuration
151+
/// \return Errors, which is a vector of Error objects. Each Error includes
152+
/// an error code and message. An empty vector indicates no error.
153+
public: Errors Load(ElementPtr _sdf, const ParserConfig &_config);
154+
132155
/// \brief Get the heightmap's URI.
133156
/// \return The URI of the heightmap data.
134157
public: std::string Uri() const;

include/sdf/Link.hh

+10
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ namespace sdf
3737
// Forward declarations.
3838
class Collision;
3939
class Light;
40+
class ParserConfig;
4041
class ParticleEmitter;
4142
class Sensor;
4243
class Visual;
@@ -56,6 +57,15 @@ namespace sdf
5657
/// an error code and message. An empty vector indicates no error.
5758
public: Errors Load(ElementPtr _sdf);
5859

60+
/// \brief Load the link based on a element pointer. This is *not* the
61+
/// usual entry point. Typical usage of the SDF DOM is through the Root
62+
/// object.
63+
/// \param[in] _sdf The SDF Element pointer
64+
/// \param[in] _config Parser configuration
65+
/// \return Errors, which is a vector of Error objects. Each Error includes
66+
/// an error code and message. An empty vector indicates no error.
67+
public: Errors Load(ElementPtr _sdf, const ParserConfig &_config);
68+
5969
/// \brief Get the name of the link.
6070
/// The name of a link must be unique within the scope of a Model.
6171
/// \return Name of the link.

include/sdf/Material.hh

+10
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ namespace sdf
3131
//
3232

3333
// Forward declarations.
34+
class ParserConfig;
3435
class Pbr;
3536

3637
enum class ShaderType : int
@@ -55,6 +56,15 @@ namespace sdf
5556
/// an error code and message. An empty vector indicates no error.
5657
public: Errors Load(ElementPtr _sdf);
5758

59+
/// \brief Load the material based on a element pointer. This is *not* the
60+
/// usual entry point. Typical usage of the SDF DOM is through the Root
61+
/// object.
62+
/// \param[in] _sdf The SDF Element pointer
63+
/// \param[in] _config Parser configuration
64+
/// \return Errors, which is a vector of Error objects. Each Error includes
65+
/// an error code and message. An empty vector indicates no error.
66+
public: Errors Load(sdf::ElementPtr _sdf, const ParserConfig &_config);
67+
5868
/// \brief Get the ambient color. The ambient color is
5969
/// specified by a set of three numbers representing red/green/blue,
6070
/// each in the range of [0,1].

include/sdf/Mesh.hh

+12
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ namespace sdf
3030
inline namespace SDF_VERSION_NAMESPACE {
3131
//
3232

33+
// Forward declarations.
34+
class ParserConfig;
35+
3336
/// \brief Mesh represents a mesh shape, and is usually accessed through a
3437
/// Geometry.
3538
class SDFORMAT_VISIBLE Mesh
@@ -45,6 +48,15 @@ namespace sdf
4548
/// an error code and message. An empty vector indicates no error.
4649
public: Errors Load(ElementPtr _sdf);
4750

51+
/// \brief Load the mesh geometry based on a element pointer.
52+
/// This is *not* the usual entry point. Typical usage of the SDF DOM is
53+
/// through the Root object.
54+
/// \param[in] _sdf The SDF Element pointer
55+
/// \param[in] _config Parser configuration
56+
/// \return Errors, which is a vector of Error objects. Each Error includes
57+
/// an error code and message. An empty vector indicates no error.
58+
public: Errors Load(sdf::ElementPtr _sdf, const ParserConfig &_config);
59+
4860
/// \brief Get the mesh's URI.
4961
/// \return The URI of the mesh data.
5062
public: std::string Uri() const;

include/sdf/ParserConfig.hh

+18
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,29 @@ class SDFORMAT_VISIBLE ParserConfig
169169
public: const std::vector<CustomModelParser> &CustomModelParsers() const;
170170

171171
/// \brief Set the preserveFixedJoint flag.
172+
/// \param[in] _preserveFixedJoint flag value to set
172173
public: void URDFSetPreserveFixedJoint(bool _preserveFixedJoint);
173174

174175
/// \brief Get the preserveFixedJoint flag value.
176+
/// \return Current flag value
175177
public: bool URDFPreserveFixedJoint() const;
176178

179+
/// \brief Set the storeResolvedURIs flag value.
180+
/// \param[in] _resolveURI True to make the parser attempt to resolve any
181+
/// URIs found and store them. False to preserve original URIs
182+
///
183+
/// The Parser will use the FindFileCallback provided to attempt to resolve
184+
/// URIs in the Mesh, Material, Heightmap, and Skybox DOM objects
185+
/// If the FindFileCallback provides a non-empty string, the URI will be
186+
/// stored in the DOM object, and the original (unresolved) URI will be
187+
/// stored in the underlying Element.
188+
public: void SetStoreResovledURIs(bool _resolveURI);
189+
190+
/// \brief Get the storeResolvedURIs flag value.
191+
/// \return True if the parser will attempt to resolve any URIs found and
192+
/// store them. False to preserve original URIs
193+
public: bool StoreResolvedURIs() const;
194+
177195
/// \brief Private data pointer.
178196
GZ_UTILS_IMPL_PTR(dataPtr)
179197
};

include/sdf/Scene.hh

+9
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ namespace sdf
4343
/// an error code and message. An empty vector indicates no error.
4444
public: Errors Load(ElementPtr _sdf);
4545

46+
/// \brief Load the scene based on a element pointer. This is *not* the
47+
/// usual entry point. Typical usage of the SDF DOM is through the Root
48+
/// object.
49+
/// \param[in] _sdf The SDF Element pointer
50+
/// \param[in] _config Parser configuration
51+
/// \return Errors, which is a vector of Error objects. Each Error includes
52+
/// an error code and message. An empty vector indicates no error.
53+
public: Errors Load(sdf::ElementPtr _sdf, const ParserConfig &_config);
54+
4655
/// \brief Get the ambient color of the scene
4756
/// \return Scene ambient color
4857
public: gz::math::Color Ambient() const;

include/sdf/Sky.hh

+13
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ namespace sdf
3232
{
3333
// Inline bracket to help doxygen filtering.
3434
inline namespace SDF_VERSION_NAMESPACE {
35+
//
36+
37+
// Forward declarations.
38+
class ParserConfig;
39+
3540
class SDFORMAT_VISIBLE Sky
3641
{
3742
/// \brief Default constructor
@@ -117,6 +122,14 @@ namespace sdf
117122
/// an error code and message. An empty vector indicates no error.
118123
public: Errors Load(ElementPtr _sdf);
119124

125+
/// \brief Load the sky based on a element pointer. This is *not* the
126+
/// usual entry point. Typical usage of the SDF DOM is through the Root
127+
/// object.
128+
/// \param[in] _sdf The SDF Element pointer
129+
/// \return Errors, which is a vector of Error objects. Each Error includes
130+
/// an error code and message. An empty vector indicates no error.
131+
public: Errors Load(ElementPtr _sdf, const ParserConfig &_config);
132+
120133
/// \brief Get a pointer to the SDF element that was used during
121134
/// load.
122135
/// \return SDF element pointer. The value will be nullptr if Load has

include/sdf/Visual.hh

+10
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ namespace sdf
4141

4242
// Forward declarations.
4343
class Geometry;
44+
class ParserConfig;
4445
struct PoseRelativeToGraph;
4546
template <typename T> class ScopedGraph;
4647

@@ -57,6 +58,15 @@ namespace sdf
5758
/// an error code and message. An empty vector indicates no error.
5859
public: Errors Load(ElementPtr _sdf);
5960

61+
/// \brief Load the visual based on a element pointer. This is *not* the
62+
/// usual entry point. Typical usage of the SDF DOM is through the Root
63+
/// object.
64+
/// \param[in] _sdf The SDF Element pointer
65+
/// \param[in] _config Parser configuration
66+
/// \return Errors, which is a vector of Error objects. Each Error includes
67+
/// an error code and message. An empty vector indicates no error.
68+
public: Errors Load(ElementPtr _sdf, const ParserConfig &_config);
69+
6070
/// \brief Get the name of the visual.
6171
/// The name of the visual must be unique within the scope of a Link.
6272
/// \return Name of the visual.

src/Collision.cc

+8-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ Collision::Collision()
6464

6565
/////////////////////////////////////////////////
6666
Errors Collision::Load(ElementPtr _sdf)
67+
{
68+
return this->Load(_sdf, ParserConfig::GlobalConfig());
69+
}
70+
71+
/////////////////////////////////////////////////
72+
Errors Collision::Load(ElementPtr _sdf, const ParserConfig &_config)
6773
{
6874
Errors errors;
6975

@@ -98,7 +104,8 @@ Errors Collision::Load(ElementPtr _sdf)
98104
loadPose(_sdf, this->dataPtr->pose, this->dataPtr->poseRelativeTo);
99105

100106
// Load the geometry
101-
Errors geomErr = this->dataPtr->geom.Load(_sdf->GetElement("geometry"));
107+
Errors geomErr = this->dataPtr->geom.Load(
108+
_sdf->GetElement("geometry"), _config);
102109
errors.insert(errors.end(), geomErr.begin(), geomErr.end());
103110

104111
// Load the surface parameters if they are given

src/Geometry.cc

+9-2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ Geometry::Geometry()
7878

7979
/////////////////////////////////////////////////
8080
Errors Geometry::Load(ElementPtr _sdf)
81+
{
82+
return this->Load(_sdf, ParserConfig::GlobalConfig());
83+
}
84+
85+
/////////////////////////////////////////////////
86+
Errors Geometry::Load(ElementPtr _sdf, const ParserConfig &_config)
8187
{
8288
Errors errors;
8389

@@ -148,14 +154,15 @@ Errors Geometry::Load(ElementPtr _sdf)
148154
{
149155
this->dataPtr->type = GeometryType::MESH;
150156
this->dataPtr->mesh.emplace();
151-
Errors err = this->dataPtr->mesh->Load(_sdf->GetElement("mesh"));
157+
Errors err = this->dataPtr->mesh->Load(_sdf->GetElement("mesh"), _config);
152158
errors.insert(errors.end(), err.begin(), err.end());
153159
}
154160
else if (_sdf->HasElement("heightmap"))
155161
{
156162
this->dataPtr->type = GeometryType::HEIGHTMAP;
157163
this->dataPtr->heightmap.emplace();
158-
Errors err = this->dataPtr->heightmap->Load(_sdf->GetElement("heightmap"));
164+
Errors err = this->dataPtr->heightmap->Load(
165+
_sdf->GetElement("heightmap"), _config);
159166
errors.insert(errors.end(), err.begin(), err.end());
160167
}
161168
else if (_sdf->HasElement("polyline"))

src/Heightmap.cc

+22-6
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ HeightmapTexture::HeightmapTexture()
9191

9292
/////////////////////////////////////////////////
9393
Errors HeightmapTexture::Load(ElementPtr _sdf)
94+
{
95+
return this->Load(_sdf, ParserConfig::GlobalConfig());
96+
}
97+
98+
/////////////////////////////////////////////////
99+
Errors HeightmapTexture::Load(ElementPtr _sdf, const ParserConfig &_config)
94100
{
95101
Errors errors;
96102

@@ -126,8 +132,9 @@ Errors HeightmapTexture::Load(ElementPtr _sdf)
126132

127133
if (_sdf->HasElement("diffuse"))
128134
{
129-
this->dataPtr->diffuse = _sdf->Get<std::string>("diffuse",
130-
this->dataPtr->diffuse).first;
135+
this->dataPtr->diffuse = resolveURI(
136+
_sdf->Get<std::string>("diffuse", this->dataPtr->diffuse).first,
137+
_config, errors);
131138
}
132139
else
133140
{
@@ -137,8 +144,9 @@ Errors HeightmapTexture::Load(ElementPtr _sdf)
137144

138145
if (_sdf->HasElement("normal"))
139146
{
140-
this->dataPtr->normal = _sdf->Get<std::string>("normal",
141-
this->dataPtr->normal).first;
147+
this->dataPtr->normal = resolveURI(
148+
_sdf->Get<std::string>("normal", this->dataPtr->normal).first,
149+
_config, errors);
142150
}
143151
else
144152
{
@@ -285,6 +293,12 @@ Heightmap::Heightmap()
285293

286294
/////////////////////////////////////////////////
287295
Errors Heightmap::Load(ElementPtr _sdf)
296+
{
297+
return this->Load(_sdf, ParserConfig::GlobalConfig());
298+
}
299+
300+
/////////////////////////////////////////////////
301+
Errors Heightmap::Load(ElementPtr _sdf, const ParserConfig &_config)
288302
{
289303
Errors errors;
290304

@@ -311,7 +325,9 @@ Errors Heightmap::Load(ElementPtr _sdf)
311325

312326
if (_sdf->HasElement("uri"))
313327
{
314-
this->dataPtr->uri = _sdf->Get<std::string>("uri", "").first;
328+
this->dataPtr->uri = resolveURI(
329+
_sdf->Get<std::string>("uri", "").first,
330+
_config, errors);
315331
}
316332
else
317333
{
@@ -332,7 +348,7 @@ Errors Heightmap::Load(ElementPtr _sdf)
332348
this->dataPtr->sampling).first;
333349

334350
Errors textureLoadErrors = loadRepeated<HeightmapTexture>(_sdf,
335-
"texture", this->dataPtr->textures);
351+
"texture", this->dataPtr->textures, _config);
336352
errors.insert(errors.end(), textureLoadErrors.begin(),
337353
textureLoadErrors.end());
338354

0 commit comments

Comments
 (0)