42 double r{ 0 }, l{ 0 };
43 if (xml_element->QueryDoubleAttribute(
"length", &(l)) != tinyxml2::XML_SUCCESS || !(l > 0))
44 std::throw_with_nested(std::runtime_error(
"Capsule: Missing or failed parsing attribute 'length'!"));
46 if (xml_element->QueryDoubleAttribute(
"radius", &(
r)) != tinyxml2::XML_SUCCESS || !(
r > 0))
47 std::throw_with_nested(std::runtime_error(
"Capsule: Missing or failed parsing attribute 'radius'!"));
49 return std::make_shared<tesseract_geometry::Capsule>(
r, l);
52 tinyxml2::XMLElement*
writeCapsule(
const std::shared_ptr<const tesseract_geometry::Capsule>& capsule,
53 tinyxml2::XMLDocument& doc)
55 if (capsule ==
nullptr)
56 std::throw_with_nested(std::runtime_error(
"Capsule is nullptr and cannot be written to XML file"));
58 xml_element->SetAttribute(
"length",
toString(capsule->getLength()).c_str());
59 xml_element->SetAttribute(
"radius",
toString(capsule->getRadius()).c_str());