MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / parseMaterial

Function parseMaterial

pj_scene3D/widgets/src/urdf_parser.cpp:139–159  ·  view source on GitHub ↗

Fills geom.color and sets geom.has_color when an inline or named color is found; otherwise leaves the LinkGeom defaults.

Source from the content-addressed store, hash-verified

137// Fills geom.color and sets geom.has_color when an inline or named color is
138// found; otherwise leaves the LinkGeom defaults.
139void parseMaterial(
140 const QDomElement& parent, const std::unordered_map<std::string, glm::vec4>& materials, LinkGeom& geom) {
141 const QDomElement mat = parent.firstChildElement(QStringLiteral("material"));
142 if (mat.isNull()) {
143 return;
144 }
145 if (auto rgba = readColorRgba(mat.firstChildElement(QStringLiteral("color")))) {
146 geom.color = *rgba;
147 geom.has_color = true;
148 return;
149 }
150 // Named material reference: <material name="Foo"/> with no inline color.
151 const std::string name = mat.attribute(QStringLiteral("name")).toStdString();
152 if (!name.empty()) {
153 auto it = materials.find(name);
154 if (it != materials.end()) {
155 geom.color = it->second;
156 geom.has_color = true;
157 }
158 }
159}
160
161// Parse a single <visual> or <collision> into a LinkGeom. Returns false if it
162// has no recognizable geometry.

Callers 1

parseGeomElementFunction · 0.85

Calls 5

readColorRgbaFunction · 0.85
isNullMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected