From 2eff2a965d16ab7cac42745d74cb416b39150599 Mon Sep 17 00:00:00 2001 From: Lingjie Zhu Date: Wed, 13 Jun 2018 15:28:06 +0800 Subject: [PATCH] deal with degeneracy in examples --- .../vsa_isotropic_metric_example.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_isotropic_metric_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_isotropic_metric_example.cpp index ffc6647cb13..b6bacd90828 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_isotropic_metric_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_isotropic_metric_example.cpp @@ -52,7 +52,12 @@ struct Compact_metric_point_proxy center = center + (center_pmap[f] - CGAL::ORIGIN) * 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; }