| 50 | } |
| 51 | |
| 52 | int main(int /*argc*/, char** /*argv*/) { |
| 53 | |
| 54 | cout << endl; |
| 55 | cout << "generating example map" << endl; |
| 56 | |
| 57 | OcTree tree (0.1); // create empty tree with resolution 0.1 |
| 58 | |
| 59 | |
| 60 | // insert some measurements of occupied cells |
| 61 | |
| 62 | for (int x=-20; x<20; x++) { |
| 63 | for (int y=-20; y<20; y++) { |
| 64 | for (int z=-20; z<20; z++) { |
| 65 | point3d endpoint ((float) x*0.05f, (float) y*0.05f, (float) z*0.05f); |
| 66 | tree.updateNode(endpoint, true); // integrate 'occupied' measurement |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | // insert some measurements of free cells |
| 72 | |
| 73 | for (int x=-30; x<30; x++) { |
| 74 | for (int y=-30; y<30; y++) { |
| 75 | for (int z=-30; z<30; z++) { |
| 76 | point3d endpoint ((float) x*0.02f-1.0f, (float) y*0.02f-1.0f, (float) z*0.02f-1.0f); |
| 77 | tree.updateNode(endpoint, false); // integrate 'free' measurement |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | cout << endl; |
| 83 | cout << "performing some queries around the desired voxel:" << endl; |
| 84 | |
| 85 | point3d query; |
| 86 | OcTreeNode* result = NULL; |
| 87 | |
| 88 | for(float z = -0.6f; z < -0.21f; z += 0.1f){ |
| 89 | for(float y = -0.6f; y < -0.21f; y += 0.1f){ |
| 90 | for(float x = -0.6f; x < -0.21f; x += 0.1f){ |
| 91 | query = point3d(x, y, z); |
| 92 | result = tree.search(query); |
| 93 | print_query_info(query, result); |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | query = point3d(-0.5f, -0.4f, -0.4f); |
| 99 | result = tree.search(query); |
| 100 | |
| 101 | vector<point3d> normals; |
| 102 | if (tree.getNormals(query, normals)){ |
| 103 | |
| 104 | cout << endl; |
| 105 | string s_norm = (normals.size() > 1) ? " normals " : " normal "; |
| 106 | cout << "MC algorithm gives " << normals.size() << s_norm << "in voxel at " << query << endl; |
| 107 | for(unsigned i = 0; i < normals.size(); ++i) |
| 108 | cout << "\t" << normals[i].x() << "; " << normals[i].y() << "; " << normals[i].z() << endl; |
| 109 | } else{ |
nothing calls this directly
no test coverage detected