mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-04 09:00:38 +08:00
Some tests for maximum values of 32bit point coordinates.
This commit is contained in:
parent
1d3e5a9f24
commit
532913bade
@ -86,7 +86,13 @@ inline IntPoint IntPoint2d(cInt x, cInt y)
|
|||||||
|
|
||||||
inline cInt Round(double val)
|
inline cInt Round(double val)
|
||||||
{
|
{
|
||||||
return static_cast<cInt>((val < 0) ? (val - 0.5) : (val + 0.5));
|
double v = val < 0 ? val - 0.5 : val + 0.5;
|
||||||
|
#if defined(CLIPPERLIB_INT32) && ! defined(NDEBUG)
|
||||||
|
static constexpr const double hi = 65536 * 16383;
|
||||||
|
if (v > hi || -v > hi)
|
||||||
|
throw clipperException("Coordinate outside allowed range");
|
||||||
|
#endif
|
||||||
|
return static_cast<cInt>(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overriding the Eigen operators because we don't want to compare Z coordinate if IntPoint is 3 dimensional.
|
// Overriding the Eigen operators because we don't want to compare Z coordinate if IntPoint is 3 dimensional.
|
||||||
|
@ -450,6 +450,19 @@ MedialAxis::MedialAxis(double min_width, double max_width, const ExPolygon &expo
|
|||||||
|
|
||||||
void MedialAxis::build(ThickPolylines* polylines)
|
void MedialAxis::build(ThickPolylines* polylines)
|
||||||
{
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
|
// Verify the scaling of the coordinates of input line segments.
|
||||||
|
for (const Line& l : m_lines) {
|
||||||
|
auto test = [](int32_t v) {
|
||||||
|
static constexpr const int32_t hi = 65536 * 16383;
|
||||||
|
assert(v <= hi && -v < hi);
|
||||||
|
};
|
||||||
|
test(l.a.x());
|
||||||
|
test(l.a.y());
|
||||||
|
test(l.b.x());
|
||||||
|
test(l.b.y());
|
||||||
|
}
|
||||||
|
#endif // NDEBUG
|
||||||
construct_voronoi(m_lines.begin(), m_lines.end(), &m_vd);
|
construct_voronoi(m_lines.begin(), m_lines.end(), &m_vd);
|
||||||
Slic3r::Voronoi::annotate_inside_outside(m_vd, m_lines);
|
Slic3r::Voronoi::annotate_inside_outside(m_vd, m_lines);
|
||||||
// static constexpr double threshold_alpha = M_PI / 12.; // 30 degrees
|
// static constexpr double threshold_alpha = M_PI / 12.; // 30 degrees
|
||||||
|
Loading…
x
Reference in New Issue
Block a user