deal with degeneracy in examples

This commit is contained in:
Lingjie Zhu 2018-06-13 15:28:06 +08:00
parent 41ea383829
commit 2eff2a965d
1 changed files with 6 additions and 1 deletions

View File

@ -52,7 +52,12 @@ struct Compact_metric_point_proxy
center = center + (center_pmap[f] - CGAL::ORIGIN) * area_pmap[f]; center = center + (center_pmap[f] - CGAL::ORIGIN) * area_pmap[f];
sum_areas += area_pmap[f]; sum_areas += area_pmap[f];
} }
center = center / sum_areas; // TODO: deal with case where sum = 0 // deal with case where sum = 0
if (center == CGAL::NULL_VECTOR || sum_areas <= FT(0.0)) {
std::cerr << "Error: degenerate geometry." << std::endl;
std::exit(EXIT_FAILURE);
}
center = center / sum_areas;
return CGAL::ORIGIN + center; return CGAL::ORIGIN + center;
} }