31 #include <boost/iostreams/device/array.hpp>
32 #include <boost/iostreams/stream.hpp>
52 std::throw_with_nested(std::runtime_error(
"Octree: Missing or failed parsing attribute 'filename'!"));
55 if (!resource || !resource->isFile())
56 std::throw_with_nested(std::runtime_error(
"Octree: Missing resource '" + filename +
"'!"));
58 auto ot = std::make_shared<octomap::OcTree>(resource->getFilePath());
60 if (ot ==
nullptr || ot->size() == 0)
61 std::throw_with_nested(std::runtime_error(
"Octree: Error importing from '" + filename +
"'!"));
66 auto geom = std::make_shared<tesseract_geometry::Octree>(ot, shape_type);
68 std::throw_with_nested(std::runtime_error(
"Octree: Error creating octree geometry type from octomap::octree!"));
74 tinyxml2::XMLDocument& doc,
75 const std::string& package_path,
76 const std::string& filename)
78 if (octree ==
nullptr)
79 std::throw_with_nested(std::runtime_error(
"Octree is nullptr and cannot be converted to XML"));
86 std::shared_ptr<octomap::OcTree> underlying_tree = std::make_shared<octomap::OcTree>(*(octree->getOctree()));
88 if (!underlying_tree->writeBinary(filepath))
89 std::throw_with_nested(std::runtime_error(
"Could not write octree to file `" + filepath +
"`!"));
91 xml_element->SetAttribute(
"filename",
makeURDFFilePath(package_path, filename).c_str());