Wildmeshing Toolkit
Loading...
Searching...
No Matches
Parameters.h
1#pragma once
2
3#include <wmtk/OptimizerParameters.h>
4
5#include <nlohmann/json.hpp>
6
7namespace wmtk::components::triwild {
10{
11 Vector2d box_min = Vector2d::Zero();
12 Vector2d box_max = Vector2d::Ones();
13
23
44
56
71 bool use_sample_envelope = false;
72
73 Parameters() = default;
74
80 Parameters(const nlohmann::json& json_params)
81 {
82 epsr = json_params["eps_rel"];
83 lr = json_params["length_rel"];
84 stop_energy = json_params["stop_energy"];
85 preserve_topology = json_params["preserve_topology"];
86 optimize_envelope_around_simplified = json_params["optimize_envelope_around_simplified"];
87 preserve_feature_points = json_params["preserve_feature_points"];
88 allow_junction_cleanup = json_params["allow_junction_cleanup"];
89
90 debug_output = json_params["DEBUG_output"];
91 perform_sanity_checks = json_params["DEBUG_sanity_checks"];
92 check_envelope_at_init = json_params["DEBUG_envelope_sanity_check"];
93 use_sample_envelope = json_params["use_sample_envelope"];
94
95 split_high_valence_threshold = json_params["split_high_valence_threshold"];
96 w_amips = json_params["w_amips"];
97 smoothing_mode = json_params["smoothing_mode"];
98 project_line_search_steps = json_params["project_line_search_steps"];
99 project_line_search_nested_steps = json_params["project_line_search_nested_steps"];
100 num_smoothing_passes = json_params["num_smoothing_passes"];
101 interleaved_smoothing = json_params["interleaved_smoothing"];
102 interleaved_smoothing_passes = json_params["interleaved_smoothing_passes"];
103
104 // Coarsening pass.
105 coarsen_pass = json_params["coarsen_pass"];
106 coarsen_unbounded = json_params["coarsen_unbounded"];
107 coarsen_local_smoothing_passes = json_params["coarsen_local_smoothing_passes"];
108 coarsen_smooth_ring = json_params["coarsen_smooth_ring"];
109 coarsen_global_smoothing_passes = json_params["coarsen_global_smoothing_passes"];
110 coarsen_max_rounds = json_params["coarsen_max_rounds"];
111 coarsen_max_inner_passes = json_params["coarsen_max_inner_passes"];
112
113 // Stuck-element sizing refinement.
114 stuck_refine_stall_eps = json_params["stuck_refine_stall_eps"];
115 stuck_refine_cooldown = json_params["stuck_refine_cooldown"];
116 stuck_refine_num_worst = json_params["stuck_refine_num_worst"];
117 stuck_refine_rings = json_params["stuck_refine_rings"];
118 stuck_refine_factor = json_params["stuck_refine_factor"];
119 stuck_refine_min_scalar = json_params["stuck_refine_min_scalar"];
120 stuck_refine_gradation = json_params["stuck_refine_gradation"];
121 stuck_refine_force_split = json_params["stuck_refine_force_split"];
122
123 // Skip good regions.
124 skip_good_regions = json_params["skip_good_regions"];
125 skip_good_regions_margin = json_params["skip_good_regions_margin"];
126 }
127
128 void init(const Vector2d& min_, const Vector2d& max_)
129 {
130 box_min = min_;
131 box_max = max_;
132 init_lengths_from_diagonal((box_max - box_min).norm());
133 l_min = eps;
134 }
135 void init(
136 const std::vector<Vector2d>& vertices,
137 const std::vector<std::array<size_t, 3>>& faces)
138 {
139 Vector2d min_, max_;
140 for (size_t i = 0; i < vertices.size(); i++) {
141 if (i == 0) {
142 min_ = vertices[i];
143 max_ = vertices[i];
144 continue;
145 }
146 for (int j = 0; j < 2; j++) {
147 if (vertices[i][j] < min_[j]) {
148 min_[j] = vertices[i][j];
149 }
150 if (vertices[i][j] > max_[j]) {
151 max_[j] = vertices[i][j];
152 }
153 }
154 }
155
156 init(min_, max_);
157 }
158};
159} // namespace wmtk::components::triwild
The parameters tetwild, triwild and simwild all share.
Definition OptimizerParameters.h:28
int project_line_search_nested_steps
Partial-projection bisections tried after it gives up; 0 disables that pass.
Definition OptimizerParameters.h:160
double w_amips
Definition OptimizerParameters.h:154
int coarsen_max_inner_passes
Definition OptimizerParameters.h:297
std::string smoothing_mode
"projected" or "exact"; see SmoothVertexOptions::SmoothingMode.
Definition OptimizerParameters.h:156
bool coarsen_pass
Definition OptimizerParameters.h:190
bool optimize_envelope_around_simplified
Definition OptimizerParameters.h:63
int coarsen_global_smoothing_passes
Definition OptimizerParameters.h:255
int coarsen_max_rounds
Definition OptimizerParameters.h:279
void init_lengths_from_diagonal(const double diag)
Derive the edge-length and envelope quantities from the bounding-box diagonal.
Definition OptimizerParameters.h:309
bool coarsen_unbounded
Definition OptimizerParameters.h:214
int split_high_valence_threshold
Definition OptimizerParameters.h:70
int coarsen_local_smoothing_passes
Definition OptimizerParameters.h:232
int project_line_search_steps
Bisections tried before the projected search gives up. See SmoothVertexOptions.
Definition OptimizerParameters.h:158
int coarsen_smooth_ring
Definition OptimizerParameters.h:248
int num_smoothing_passes
Number and placement of smoothing passes in the shared Wild optimization driver.
Definition OptimizerParameters.h:164
The fields shared with tetwild and simwild live in wmtk::OptimizerParameters.
Definition Parameters.h:10
Parameters(const nlohmann::json &json_params)
Read every optimizer knob out of the (defaults-injected) JSON.
Definition Parameters.h:80
bool allow_junction_cleanup
Definition Parameters.h:43
bool use_sample_envelope
Definition Parameters.h:71
bool preserve_feature_points
Definition Parameters.h:22
bool check_envelope_at_init
Definition Parameters.h:55