From b40f12b7ff98f5a81f802e4d58c1a1843f54b09f Mon Sep 17 00:00:00 2001 From: Bastian Rieck Date: Mon, 1 Aug 2011 14:50:00 +0200 Subject: [PATCH] Fixed bug in `mesh::relax_edge()`; removed obsolete code --- mesh.cpp | 10 +++++++++- mesh.h | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mesh.cpp b/mesh.cpp index 092691c..6bafb69 100644 --- a/mesh.cpp +++ b/mesh.cpp @@ -1372,6 +1372,13 @@ bool mesh::relax_edge(edge* e) double theta = acos(a.normalize()*b.normalize()); // interior angle between a and b double r = (A-B).length()/(2*sin(theta)); // circumradius + if(r == std::numeric_limits::infinity() || + std::isnan(r) || + theta == 0.0) + { + return(false); + } + v3ctor d = (a|b); // vector perpendicular to a and b; used in // the formula below double d_len = d.length(); @@ -1390,7 +1397,8 @@ bool mesh::relax_edge(edge* e) if(v != e->get_u() && v != e->get_v()) { // ...and check whether it is outside the circumcircle - swap = (v->get_position() - c).length() < r; + swap = (v->get_position() - c).length() < r - 5*std::numeric_limits::epsilon(); // Why we used a factor of 5 times epsilon is left as an easy + // exercise to the reader // Set new vertices if(v1) diff --git a/mesh.h b/mesh.h index 2bde282..350093d 100644 --- a/mesh.h +++ b/mesh.h @@ -116,7 +116,6 @@ class mesh bool load_ply(std::istream& in); bool load_obj(std::istream& in); bool load_off(std::istream& in); - bool load_pline(std::istream& in); bool save_ply(std::ostream& out); bool save_obj(std::ostream& out);