31 #include <boost/algorithm/string.hpp>
43 std::string size_string;
45 std::throw_with_nested(std::runtime_error(
"Box: Missing or failed parsing box attribute size!"));
47 std::vector<std::string> tokens;
48 boost::split(tokens, size_string, boost::is_any_of(
" "), boost::token_compress_on);
50 std::throw_with_nested(std::runtime_error(
"Box: Failed converting box attribute size to vector!"));
52 double l{ 0 }, w{ 0 }, h{ 0 };
59 std::throw_with_nested(std::runtime_error(
"Box: The length must be greater than zero!"));
62 std::throw_with_nested(std::runtime_error(
"Box: The width must be greater than zero!"));
65 std::throw_with_nested(std::runtime_error(
"Box: The height must be greater than zero!"));
67 return std::make_shared<tesseract_geometry::Box>(l, w, h);
70 tinyxml2::XMLElement*
writeBox(
const std::shared_ptr<const tesseract_geometry::Box>& box, tinyxml2::XMLDocument& doc)
73 std::throw_with_nested(std::runtime_error(
"Box is nullptr and cannot be converted to XML"));
75 Eigen::IOFormat eigen_format(Eigen::StreamPrecision, Eigen::DontAlignCols,
" ",
" ");
76 std::stringstream size_string;
77 size_string << Eigen::Vector3d(box->getX(), box->getY(), box->getZ()).format(eigen_format);
78 xml_element->SetAttribute(
"size", size_string.str().c_str());