46 std::ofstream file(filename.c_str(), std::ios_base::out | std::ios_base::binary);
62 s <<
fileHeader <<
"\n# (feel free to add / change comments, but leave the first line as it is!)\n#\n";
64 s <<
"size "<<
size() << std::endl;
66 s <<
"data" << std::endl;
75 std::ifstream file(filename.c_str(), std::ios_base::in |std::ios_base::binary);
91 std::getline(s, line);
125 bool headerRead =
false;
126 while(s.good() && !headerRead) {
128 if (token ==
"data"){
134 }
while(s.good() && (c !=
'\n'));
136 else if (token.compare(0,1,
"#") == 0){
141 }
while(s.good() && (c !=
'\n'));
143 else if (token ==
"id")
145 else if (token ==
"res")
147 else if (token ==
"size")
154 }
while(s.good() && (c !=
'\n'));
176 OCTOMAP_WARNING(
"You are using a deprecated id \"%s\", changing to \"OcTree\" (you should update your file header)\n",
id.c_str());
185 std::map<std::string, AbstractOcTree*>::iterator it =
classIDMapping().find(class_name);
187 OCTOMAP_ERROR(
"Could not create octree of type %s, not in store in classIDMapping\n", class_name.c_str());
201 static std::map<std::string, AbstractOcTree*>* map =
new std::map<std::string, AbstractOcTree*>();
static void registerTreeType(AbstractOcTree *tree)
virtual std::string getTreeType() const =0
returns actual class name as string for identification
static AbstractOcTree * read(const std::string &filename)
virtual std::istream & readData(std::istream &s)=0
static bool readHeader(std::istream &s, std::string &id, unsigned &size, double &res)
virtual size_t size() const =0
virtual std::ostream & writeData(std::ostream &s) const =0
virtual double getResolution() const =0
static AbstractOcTree * createTree(const std::string id, double res)
#define OCTOMAP_WARNING(...)
#define OCTOMAP_WARNING_STR(args)
#define OCTOMAP_ERROR_STR(args)
static std::map< std::string, AbstractOcTree * > & classIDMapping()
create private store, Construct on first use
#define OCTOMAP_DEBUG_STR(args)
virtual void setResolution(double res)=0
bool write(const std::string &filename) const
Write file header and complete tree to file (serialization)
virtual AbstractOcTree * create() const =0
virtual constructor: creates a new object of same type
#define OCTOMAP_ERROR(...)
static const std::string fileHeader