| 82 | Eigen::MatrixXd weights(500000, 500); |
| 83 | |
| 84 | int main(int argc, char *argv[]) { |
| 85 | |
| 86 | freopen(argv[1], "r", stdin); // w_mesh |
| 87 | int n, m, n_keypoints; |
| 88 | scanf("%d %d", &n, &n_keypoints); |
| 89 | for (int i = 0; i < n; i++) |
| 90 | for (int j = 0; j < n_keypoints; j++) { |
| 91 | double t; |
| 92 | scanf("%lf", &t); |
| 93 | weights(i, j) = t; |
| 94 | } |
| 95 | |
| 96 | if (!igl::readOBJ(argv[2], surface.V, surface.F)) // surface mesh |
| 97 | { |
| 98 | std::cout << "failed to load mesh" << std::endl; |
| 99 | } |
| 100 | assert(n == surface.V.rows()); |
| 101 | m = surface.F.rows(); |
| 102 | |
| 103 | std::vector<Point> mesh_vertices; |
| 104 | for (int i = 0; i < n; i++) |
| 105 | { |
| 106 | mesh_vertices.push_back(Point(surface.V(i, 0), surface.V(i, 1), surface.V(i, 2))); |
| 107 | } |
| 108 | |
| 109 | float surface_area = 0; |
| 110 | for (int i = 0; i < m; i++) |
| 111 | { |
| 112 | Point A = mesh_vertices[surface.F(i, 0)]; |
| 113 | Point B = mesh_vertices[surface.F(i, 1)]; |
| 114 | Point C = mesh_vertices[surface.F(i, 2)]; |
| 115 | surface_area += (B - A).cross(C - A).length(); |
| 116 | } |
| 117 | //printf("%f\n", surface_area); |
| 118 | |
| 119 | const int n_sampled_points = 4096; |
| 120 | int cnt = 0; |
| 121 | int tt = m / n_sampled_points + 2; |
| 122 | Eigen::MatrixXd sampled_points(n_sampled_points, 3); |
| 123 | Eigen::MatrixXd null_set; |
| 124 | |
| 125 | freopen(argv[3], "w", stdout); // w_mesh_4096 |
| 126 | printf("%d %d\n", n_sampled_points, n_keypoints); |
| 127 | for (int i = 0; i < m; i++) |
| 128 | { |
| 129 | int a = surface.F(i, 0); |
| 130 | int b = surface.F(i, 1); |
| 131 | int c = surface.F(i, 2); |
| 132 | Point A = mesh_vertices[a]; |
| 133 | Point B = mesh_vertices[b]; |
| 134 | Point C = mesh_vertices[c]; |
| 135 | float area = (B - A).cross(C - A).length(); |
| 136 | int t = std::max(1.0f, n_sampled_points * tt * (area / surface_area)); |
| 137 | if (i == m - 1) |
| 138 | t = n_sampled_points * tt - t; |
| 139 | if (cnt + t > n_sampled_points * tt) |
| 140 | t = n_sampled_points * tt - cnt; |
| 141 | for (int j = 0; j < t; j++) { |
nothing calls this directly
no test coverage detected