Skip to content

Commit

Permalink
Fixed bug in mesh::relax_edge(); removed obsolete code
Browse files Browse the repository at this point in the history
  • Loading branch information
Pseudomanifold committed Aug 1, 2011
1 parent f5188bd commit b40f12b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 9 additions & 1 deletion mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>::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();
Expand All @@ -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<double>::epsilon(); // Why we used a factor of 5 times epsilon is left as an easy
// exercise to the reader

// Set new vertices
if(v1)
Expand Down
1 change: 0 additions & 1 deletion mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b40f12b

Please sign in to comment.