38 #include <boost/version.hpp>
39 #if BOOST_VERSION < 104400
40 #warning Boost version >= 1.44 is required for PlannerDataStorage classes
43 #include "ompl/base/PlannerDataStorage.h"
44 #include <boost/archive/archive_exception.hpp>
46 static const boost::uint32_t OMPL_PLANNER_DATA_ARCHIVE_MARKER = 0x5044414D;
58 std::ofstream out(filename, std::ios::binary);
68 OMPL_ERROR(
"Failed to store PlannerData: output stream is invalid");
73 OMPL_ERROR(
"Failed to store PlannerData: SpaceInformation is invalid");
78 boost::archive::binary_oarchive oa(out);
82 h.
marker = OMPL_PLANNER_DATA_ARCHIVE_MARKER;
85 si->getStateSpace()->computeSignature(h.
signature);
88 storeVertices(pd, oa);
91 catch (boost::archive::archive_exception &ae)
93 OMPL_ERROR(
"Failed to store PlannerData: %s", ae.what());
99 std::ifstream in(filename, std::ios::binary);
111 OMPL_ERROR(
"Failed to load PlannerData: input stream is invalid");
116 OMPL_ERROR(
"Failed to load PlannerData: SpaceInformation is invalid");
122 boost::archive::binary_iarchive ia(in);
129 if (h.marker != OMPL_PLANNER_DATA_ARCHIVE_MARKER)
131 OMPL_ERROR(
"Failed to load PlannerData: PlannerData archive marker not found");
136 std::vector<int> sig;
137 si->getStateSpace()->computeSignature(sig);
138 if (h.signature != sig)
140 OMPL_ERROR(
"Failed to load PlannerData: StateSpace signature mismatch");
145 loadVertices(pd, h.vertex_count, ia);
146 loadEdges(pd, h.edge_count, ia);
148 catch (boost::archive::archive_exception &ae)
150 OMPL_ERROR(
"Failed to load PlannerData: %s", ae.what());
unsigned int numVertices(void) const
Retrieve the number of vertices in this structure.
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
virtual void load(const char *filename, PlannerData &pd)
Load the PlannerData structure from the given stream. The StateSpace that was used to store the data ...
#define OMPL_ERROR(fmt,...)
Log a formatted error string.
PlannerDataStorage(void)
Default constructor.
const SpaceInformationPtr & getSpaceInformation(void) const
Return the instance of SpaceInformation used in this PlannerData.
virtual void clear(void)
Clears the entire data structure.
virtual ~PlannerDataStorage(void)
Destructor.
unsigned int numEdges(void) const
Retrieve the number of edges in this structure.
virtual void store(const PlannerData &pd, const char *filename)
Store (serialize) the PlannerData structure to the given filename.