// Global variables used: documents_map, db void vtree_user::load_database(const std::string directory) { ROS_INFO("Loading the tree..."); std::string tree_file(directory + "/clouds.tree"); tree.load(tree_file.c_str()); ROS_INFO("Initializing the database..."); db = new vt::Database(tree.words()); std::string documents_file(directory + "/clouds.documents"); ROS_INFO("Loading the documents... (%s)", documents_file.c_str()); std::ifstream in(documents_file.c_str(), std::ios::in | std::ios::binary); size_t map_size; in.read((char*) &map_size, sizeof(size_t)); for (size_t i = 0; i < map_size; ++i) { int id; DocumentInfo* document_info = new DocumentInfo(); in.read((char*) &id, sizeof(int)); document_info->read(in); vt::Document* doc = document_info->document; int d = db->insert(*doc); documents_map[d] = document_info; } ROS_INFO("Loading weights..."); std::string weights_file(directory + "/clouds.weights"); db->loadWeights(weights_file.c_str()); in.close(); ROS_INFO("READY!"); }
// Global variables used: tree void vtree_user::save_database( const std::string directory ) { ROS_INFO("Saving the tree..."); std::string tree_file(directory + "/clouds.tree"); tree.save(tree_file.c_str()); save_database_without_tree(directory); }
void IOManager<B,F>::writeCollisionTree(string filename) { cout << "Writing Collision Tree " << filename << " ..."; fstream tree_file(filename.c_str(), ios::out); tree_file << simulator.getCollisionTree(); tree_file.close(); cout << "Done" << endl; }
void HuffmanCodeTreeTraversals(Node*& tree_node) { std::ofstream tree_file("tree.txt"); if (tree_file.is_open()) { HuffmanCodeTreePreOrder(tree_node, tree_file); tree_file << "\n"; HuffmanCodeTreeInOrder(tree_node, tree_file); tree_file << "\n"; } tree_file.close(); }