45 std::cerr <<
"\nUSAGE: " <<
self <<
" input.bt\n\n";
47 std::cerr <<
"This tool will convert the occupied voxels of a binary OctoMap \n" 48 "file input.bt to a VRML2.0 file input.bt.wrl.\n\n";
50 std::cerr <<
"WARNING: The output files will be quite large!\n\n";
55 int main(
int argc,
char** argv) {
57 string vrmlFilename =
"";
58 string btFilename =
"";
60 if (argc != 2 || (argc > 1 && strcmp(argv[1],
"-h") == 0)){
64 btFilename = std::string(argv[1]);
65 vrmlFilename = btFilename +
".wrl";
68 cout <<
"\nReading OcTree file\n===========================\n";
73 cout <<
"\nWriting occupied volumes to VRML\n===========================\n";
75 std::ofstream outfile (vrmlFilename.c_str());
77 outfile <<
"#VRML V2.0 utf8\n#\n";
78 outfile <<
"# created from OctoMap file "<<btFilename<<
" with bt2vrml\n";
82 for(OcTree::leaf_iterator it = tree->
begin(), end=tree->
end(); it!= end; ++it) {
85 double size = it.getSize();
86 outfile <<
"Transform { translation " 87 << it.getX() <<
" " << it.getY() <<
" " << it.getZ()
89 <<
" Shape { geometry Box { size " 90 << size <<
" " << size <<
" " << size <<
"} } ]\n" 99 std::cout <<
"Finished writing "<< count <<
" voxels to " << vrmlFilename << std::endl;
const iterator end() const
int main(int argc, char **argv)
iterator begin(unsigned char maxDepth=0) const
void printUsage(char *self)
bool isNodeOccupied(const OcTreeNode *occupancyNode) const
queries whether a node is occupied according to the tree's parameter for "occupancy" ...