Mesh_2: sort the sequence tr.subconstraints_begin(), tr.subconstraints_end()

This commit is contained in:
Laurent Rineau 2024-06-13 16:31:32 +02:00
parent 93fd96644c
commit 82b53596fd
1 changed files with 19 additions and 5 deletions

View File

@ -346,12 +346,26 @@ protected:
{ {
// with constraint hierarchy // with constraint hierarchy
for(typename Tr::Subconstraint_iterator it = tr.subconstraints_begin(); // create a vector of pairs of vertex handles, from the subconstraints
it != tr.subconstraints_end(); ++it) // and sort it to ensure the determinism
{ std::vector<std::array<Vertex_handle, 2>> subconstraints_vector(tr.number_of_subconstraints());
const Vertex_handle& v1 = it->first.first; std::transform(tr.subconstraints_begin(), tr.subconstraints_end(), subconstraints_vector.begin(),
const Vertex_handle& v2 = it->first.second; [](const auto& sc) {
return std::array<Vertex_handle, 2>{sc.first.first, sc.first.second};
});
auto comp_vh = [&] (Vertex_handle va, Vertex_handle vb) {
return tr.compare_xy(va->point(), vb->point()) == SMALLER;
};
auto comp_pair_vh = [&] (const auto& e1, const auto& e2) {
return comp_vh(e1[0], e2[0]) ||
(!comp_vh(e2[0], e1[0]) && comp_vh(e1[1], e2[1]));
};
std::sort(subconstraints_vector.begin(), subconstraints_vector.end(), comp_pair_vh);
for(const auto& [v1, v2] : subconstraints_vector)
{
if(!is_locally_conform(tr, v1, v2) ){ if(!is_locally_conform(tr, v1, v2) ){
add_constrained_edge_to_be_conformed(v1, v2); add_constrained_edge_to_be_conformed(v1, v2);
} }