mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-04 03:40:38 +08:00
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. #3776
This commit is contained in:
parent
a69e4e39c9
commit
9ad1360e44
@ -19,7 +19,8 @@ namespace Slic3r {
|
||||
// How about 2^17=131072?
|
||||
// By the way, is the scalling needed at all? Cura runs all the computation with a fixed point precision of 1um, while Slic3r scales to 1nm,
|
||||
// further scaling by 10e5 brings us to
|
||||
#define CLIPPER_OFFSET_SCALE 100000.0
|
||||
static const float CLIPPER_OFFSET_SCALE = 100000.0;
|
||||
static const coord_t MAX_COORD = ClipperLib::hiRange / CLIPPER_OFFSET_SCALE;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// legacy code from Clipper documentation
|
||||
|
@ -514,4 +514,12 @@ ExPolygon::dump_perl() const
|
||||
return ret.str();
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
operator <<(std::ostream &s, const ExPolygons &expolygons)
|
||||
{
|
||||
for (const ExPolygon &e : expolygons)
|
||||
s << e.dump_perl() << std::endl;
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "libslic3r.h"
|
||||
#include "Polygon.hpp"
|
||||
#include "Polyline.hpp"
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
|
||||
namespace Slic3r {
|
||||
@ -62,6 +63,8 @@ operator+(ExPolygons src1, const ExPolygons &src2) {
|
||||
return src1;
|
||||
};
|
||||
|
||||
std::ostream& operator <<(std::ostream &s, const ExPolygons &expolygons);
|
||||
|
||||
}
|
||||
|
||||
// start Boost
|
||||
|
@ -7,13 +7,14 @@
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
|
||||
#define SLIC3R_DEBUG
|
||||
#ifdef SLIC3R_DEBUG
|
||||
#include "SVG.hpp"
|
||||
#endif
|
||||
@ -609,6 +610,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)MAX_COORD
|
||||
|| std::abs(edge->vertex0()->y()) > (double)MAX_COORD
|
||||
|| std::abs(edge->vertex1()->x()) > (double)MAX_COORD
|
||||
|| std::abs(edge->vertex1()->y()) > (double)MAX_COORD)
|
||||
return false;
|
||||
|
||||
// construct the line representing this edge of the Voronoi diagram
|
||||
const Line line(
|
||||
Point( edge->vertex0()->x(), edge->vertex0()->y() ),
|
||||
|
Loading…
x
Reference in New Issue
Block a user