41 #ifdef TESSERACT_PARSE_POINT_CLOUDS
51 std::string shape_type;
53 std::throw_with_nested(std::runtime_error(
"Octomap: Missing or failed parsing attribute 'shape_type'!"));
56 if (shape_type ==
"box")
58 else if (shape_type ==
"sphere_inside")
60 else if (shape_type ==
"sphere_outside")
63 std::throw_with_nested(std::runtime_error(
"Octomap: Invalid sub shape type, must be 'box', 'sphere_inside', or "
64 "'sphere_outside'!"));
67 xml_element->QueryBoolAttribute(
"prune", &prune);
69 const tinyxml2::XMLElement* octree_element = xml_element->FirstChildElement(
OCTREE_ELEMENT_NAME.data());
70 if (octree_element !=
nullptr)
74 return parseOctree(octree_element, locator, sub_type, prune);
78 std::throw_with_nested(std::runtime_error(
"Octomap:"));
82 #ifdef TESSERACT_PARSE_POINT_CLOUDS
84 if (pcd_element !=
nullptr)
92 std::throw_with_nested(std::runtime_error(
"Octomap:"));
97 std::throw_with_nested(std::runtime_error(
"Octomap: Missing element '" + std::string(
OCTREE_ELEMENT_NAME) +
"' or '" +
101 tinyxml2::XMLElement*
writeOctomap(
const std::shared_ptr<const tesseract_geometry::Octree>& octree,
102 tinyxml2::XMLDocument& doc,
103 const std::string& package_path,
104 const std::string& filename)
106 if (octree ==
nullptr)
107 std::throw_with_nested(std::runtime_error(
"Octree is nullptr and cannot be converted to XML"));
110 std::string type_string;
114 type_string =
"sphere_inside";
116 type_string =
"sphere_outside";
118 std::throw_with_nested(std::runtime_error(
"Octree subtype is invalid and cannot be converted to XML"));
119 xml_element->SetAttribute(
"shape_type", type_string.c_str());
121 xml_element->SetAttribute(
"prune", octree->getPruned());
125 tinyxml2::XMLElement* xml_octree =
writeOctree(octree, doc, package_path, filename);
126 xml_element->InsertEndChild(xml_octree);
130 std::throw_with_nested(std::runtime_error(
"Octomap: Could not write octree to file"));