| 10 | |
| 11 | |
| 12 | int main(int argc, char *argv[]) |
| 13 | { |
| 14 | |
| 15 | if (!igl::readOBJ(argv[1], surface.V, surface.F)) |
| 16 | { |
| 17 | std::cout << "failed to load mesh" << std::endl; |
| 18 | } |
| 19 | int n = surface.V.rows(); |
| 20 | |
| 21 | double min_x = 1e9, min_y = 1e9, min_z = 1e9; |
| 22 | double max_x = -1e9, max_y = -1e9, max_z = -1e9; |
| 23 | |
| 24 | for (int i = 0; i < n; i++) { |
| 25 | min_x = std::min(min_x, surface.V(i, 0)); |
| 26 | min_y = std::min(min_y, surface.V(i, 1)); |
| 27 | min_z = std::min(min_z, surface.V(i, 2)); |
| 28 | max_x = std::max(max_x, surface.V(i, 0)); |
| 29 | max_y = std::max(max_y, surface.V(i, 1)); |
| 30 | max_z = std::max(max_z, surface.V(i, 2)); |
| 31 | } |
| 32 | for (int i = 0; i < n; i++) { |
| 33 | surface.V(i, 0) -= (max_x + min_x) / 2; |
| 34 | surface.V(i, 1) -= (max_y + min_y) / 2; |
| 35 | surface.V(i, 2) -= (max_z + min_z) / 2; |
| 36 | } |
| 37 | double radius = 0; |
| 38 | for (int i = 0; i < n; i++) { |
| 39 | double x = surface.V(i, 0), y = surface.V(i, 1), z = surface.V(i, 2); |
| 40 | radius = std::max(radius, sqrt(x * x + y * y + z * z)); |
| 41 | } |
| 42 | |
| 43 | for (int i = 0; i < n; i++) { |
| 44 | surface.V(i, 0) /= radius; |
| 45 | surface.V(i, 1) /= radius; |
| 46 | surface.V(i, 2) /= radius; |
| 47 | } |
| 48 | igl::writeOBJ(argv[2], surface.V, surface.F); |
| 49 | return 0; |
| 50 | } |
nothing calls this directly
no outgoing calls
no test coverage detected