Skip to content
Snippets Groups Projects
Commit c49d8978 authored by Tom Fischer's avatar Tom Fischer
Browse files

[MGT] Handle case where standard deviation of edge lengths is very small.

parent e086f2fc
No related branches found
No related tags found
No related merge requests found
......@@ -47,16 +47,20 @@ HeuristicSearchLength::HeuristicSearchLength(MeshLib::Mesh const& mesh)
}
const double mu (sum/edge_cnt);
const double s (sqrt(1.0/(edge_cnt-1) * (sum_of_sqr - (sum*sum)/edge_cnt) ));
// heuristic to prevent negative search lengths
// in the case of a big standard deviation s
double c(2.0);
while (mu < c * s) {
c *= 0.9;
const double helper (sum_of_sqr - (sum*sum)/edge_cnt);
if (helper < 0.0) {
_search_length = mu/2;
} else {
const double s (sqrt(helper/(edge_cnt-1)));
// heuristic to prevent negative search lengths
// in the case of a big standard deviation s
double c(2.0);
while (mu < c * s) {
c *= 0.9;
}
_search_length = (mu - c * s)/2;
}
_search_length = (mu - c * s)/2;
DBUG("[MeshNodeSearcher::MeshNodeSearcher] Calculated search length for mesh \"%s\" is %f.",
_mesh.getName().c_str(), _search_length);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment