Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mollification step to avoid degenerate faces #5037

Merged
merged 10 commits into from
Apr 6, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,29 @@ class Intrinsic_Delaunay_triangulation_3
return CGAL::sqrt(S*(S-a)*(S-b)*(S-c));
}

// Mollification strategy to avoid degeneracies
void
mollify(double delta)
{
// compute smallest length epsilon we can add to
// all edges to ensure that the strict triangle
// inequality holds with a tolerance of delta
double epsilon = 0;
for(halfedge_descriptor hd : halfedges(m_intrinsic_tm)) {
halfedge_descriptor hd2 = next(hd, m_intrinsic_tm);
halfedge_descriptor hd3 = next(hd2,m_intrinsic_tm);
Index i = get(edge_id_map, edge(hd,m_intrinsic_tm));
Index j = get(edge_id_map, edge(hd2,m_intrinsic_tm));
Index k = get(edge_id_map, edge(hd3,m_intrinsic_tm));
double ineq = edge_lengths[j] + edge_lengths[k] - edge_lengths[i];
epsilon = std::max(epsilon, std::max(0., delta-ineq));
oboes marked this conversation as resolved.
Show resolved Hide resolved
}
// update edge lengths
for(edge_descriptor ed : edges(m_intrinsic_tm)) {
Index i = get(edge_id_map, ed);
edge_lengths[i] += epsilon;
}
}

void
loop_over_edges(edge_stack stack, std::vector<int>& marked_edges)
Expand Down Expand Up @@ -365,13 +388,16 @@ class Intrinsic_Delaunay_triangulation_3
Index edge_i = 0;
VertexPointMap vpm_intrinsic_tm = get(boost::vertex_point,m_intrinsic_tm);

double min_length = (std::numeric_limits<double>::max)();
for(edge_descriptor ed : edges(m_intrinsic_tm)) {
edge_lengths[edge_i] = CGAL::sqrt(to_double(squared_distance(get(vpm_intrinsic_tm, source(ed,m_intrinsic_tm)),
get(vpm_intrinsic_tm, target(ed,m_intrinsic_tm)))));
// Polygon_mesh_processing::edge_length(halfedge(ed,m_intrinsic_tm),m_intrinsic_tm);
if (edge_lengths[edge_i] != 0 && edge_lengths[edge_i] < min_length) min_length = edge_lengths[edge_i];
put(edge_id_map, ed, edge_i++);
stack.push(ed);
}
mollify(min_length*1e-4);
loop_over_edges(stack, mark_edges);
//now that edges are calculated, go through and for each face, calculate the vertex positions around it

Expand Down