|
1 | 1 | #include "common.hh" |
2 | 2 | #include "explicit_optimization.hh" |
3 | 3 | #include "optimization_interface.hh" |
4 | | -#include "targets.hh" |
5 | 4 | #include "optimization_interface.hh" |
6 | 5 | #include "shear.hh" |
7 | 6 | #include "logging.hh" |
@@ -32,61 +31,49 @@ int main(int argc, char *argv[]) |
32 | 31 | igl::readOBJ(input_filename, V, uv, N, F, FT, FN); |
33 | 32 |
|
34 | 33 | // Get input angles |
35 | | - std::vector<Scalar> Th_hat_init, Th_hat; |
| 34 | + std::vector<Scalar> Th_hat_init; |
36 | 35 | spdlog::info("Using cone angles at {}", Th_hat_filename); |
37 | 36 | read_vector_from_file(Th_hat_filename, Th_hat_init); |
38 | | - correct_cone_angles(Th_hat_init, Th_hat); |
| 37 | + std::vector<Scalar> Th_hat = correct_cone_angles(Th_hat_init); |
39 | 38 |
|
40 | 39 | // Get initial mesh for optimization |
41 | | - Mesh<Scalar> m; |
42 | 40 | std::vector<int> vtx_reindex; |
43 | | - VectorX reduced_metric_target; |
44 | | - generate_initial_mesh(V, F, V, F, Th_hat, m, vtx_reindex, reduced_metric_target); |
| 41 | + std::vector<int> free_cones = {}; |
| 42 | + bool fix_boundary = false; |
| 43 | + std::unique_ptr<DifferentiableConeMetric> cone_metric = generate_initial_mesh(V, F, V, F, Th_hat, vtx_reindex, free_cones, fix_boundary, false); |
45 | 44 |
|
46 | | - // Get initial metric from file or target |
47 | | - VectorX reduced_metric_init; |
48 | | - if (argc > 4) |
49 | | - { |
50 | | - std::string metric_filename = argv[4]; |
51 | | - std::vector<Scalar> reduced_metric_init_vec; |
52 | | - read_vector_from_file(metric_filename, reduced_metric_init_vec); |
53 | | - convert_std_to_eigen_vector(reduced_metric_init_vec, reduced_metric_init); |
54 | | - } else { |
55 | | - reduced_metric_init = reduced_metric_target; |
56 | | - } |
| 45 | + // Get energy |
| 46 | + LogLengthEnergy opt_energy(*cone_metric); |
57 | 47 |
|
58 | 48 | // Make default parameters |
59 | 49 | auto proj_params = std::make_shared<ProjectionParameters>(); |
60 | 50 | auto opt_params = std::make_shared<OptimizationParameters>(); |
61 | | - opt_params->output_dir = output_dir; |
62 | | - opt_params->num_iter = 500; |
| 51 | + //opt_params->output_dir = output_dir; |
| 52 | + opt_params->num_iter = 100; |
63 | 53 | opt_params->min_ratio = 0; |
64 | 54 | opt_params->max_grad_range = 10; |
65 | 55 | opt_params->direction_choice = "lbfgs"; |
66 | 56 |
|
67 | 57 | // Compute shear dual basis and the corresponding inner product matrix |
68 | 58 | MatrixX shear_basis_matrix; |
69 | 59 | std::vector<int> independent_edges; |
70 | | - compute_shear_dual_basis(m, shear_basis_matrix, independent_edges); |
| 60 | + compute_shear_dual_basis(*cone_metric, shear_basis_matrix, independent_edges); |
71 | 61 | //compute_shear_coordinate_basis(m, shear_basis_matrix, independent_edges); |
72 | 62 |
|
73 | 63 | // Compute the shear dual coordinates for this basis |
74 | 64 | VectorX shear_basis_coords_init; |
75 | 65 | VectorX scale_factors_init; |
76 | | - compute_shear_basis_coordinates(m, reduced_metric_init, shear_basis_matrix, shear_basis_coords_init, scale_factors_init); |
| 66 | + compute_shear_basis_coordinates(*cone_metric, shear_basis_matrix, shear_basis_coords_init, scale_factors_init); |
77 | 67 | spdlog::info("Initial coordinates are {}", shear_basis_coords_init); |
78 | 68 |
|
79 | 69 | // Optimize the metric |
80 | | - PennerConeMetric cone_metric(m, reduced_metric_init); |
81 | 70 | VectorX reduced_metric_coords; |
82 | | - optimize_shear_basis_coordinates(cone_metric, |
83 | | - reduced_metric_target, |
84 | | - shear_basis_coords_init, |
85 | | - scale_factors_init, |
86 | | - shear_basis_matrix, |
87 | | - reduced_metric_coords, |
88 | | - proj_params, |
89 | | - opt_params); |
| 71 | + optimize_shear_basis_coordinates( |
| 72 | + *cone_metric, |
| 73 | + opt_energy, |
| 74 | + shear_basis_matrix, |
| 75 | + proj_params, |
| 76 | + opt_params); |
90 | 77 |
|
91 | 78 | // Write the output |
92 | 79 | std::string output_filename = join_path(output_dir, "reduced_metric_coords"); |
|
0 commit comments