diff options
author | bubnikv <bubnikv@gmail.com> | 2017-03-24 11:32:30 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2017-03-24 11:32:30 +0300 |
commit | 0dae43e4bc68fb3fce2a5c6d41ba7030c7d542a5 (patch) | |
tree | 2c92fe00e5d7d10b9274eca507b9247c3125a424 /xs/src/libslic3r/Geometry.cpp | |
parent | 6162670bbd29750850e6bc6becaf64bdd0da01fd (diff) |
Bugfix: when the Voronoi diagram contained very large coordinates we need to check whether they are greater than our allowed range and consider the Voronoi edges infinite in those cases, in order to prevent overflows.
https://github.com/alexrj/Slic3r/issues/3776
https://github.com/alexrj/Slic3r/commit/9ad1360e445cd3043c4dc30ccad64b82b914f952
Diffstat (limited to 'xs/src/libslic3r/Geometry.cpp')
-rw-r--r-- | xs/src/libslic3r/Geometry.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/xs/src/libslic3r/Geometry.cpp b/xs/src/libslic3r/Geometry.cpp index 314990734..96613549a 100644 --- a/xs/src/libslic3r/Geometry.cpp +++ b/xs/src/libslic3r/Geometry.cpp @@ -983,6 +983,13 @@ MedialAxis::process_edge_neighbors(const VD::edge_type* edge, ThickPolyline* pol bool MedialAxis::validate_edge(const VD::edge_type* edge) { + // prevent overflows and detect almost-infinite edges + if (std::abs(edge->vertex0()->x()) > double(CLIPPER_MAX_COORD_UNSCALED) || + std::abs(edge->vertex0()->y()) > double(CLIPPER_MAX_COORD_UNSCALED) || + std::abs(edge->vertex1()->x()) > double(CLIPPER_MAX_COORD_UNSCALED) || + std::abs(edge->vertex1()->y()) > double(CLIPPER_MAX_COORD_UNSCALED)) + return false; + // construct the line representing this edge of the Voronoi diagram const Line line( Point( edge->vertex0()->x(), edge->vertex0()->y() ), |