Merge branch 'master' into et_tm_sla_volumes_6-SPE-1285

This commit is contained in:
tamasmeszaros 2023-01-13 10:00:57 +01:00
commit fc9b7ed59c
211 changed files with 10741 additions and 3369 deletions

View file

@ -176,6 +176,7 @@ SCENARIO("Cooling integration tests", "[Cooling]") {
{ "fan_below_layer_time", { 0 } },
{ "slowdown_below_layer_time", { 0 } },
{ "bridge_speed", 99 },
{ "enable_dynamic_overhang_speeds", false },
// internal bridges use solid_infil speed
{ "bottom_solid_layers", 1 },
// internal bridges use solid_infil speed

View file

@ -309,6 +309,7 @@ SCENARIO("Perimeters", "[Perimeters]")
{ "perimeters", 1 },
{ "perimeter_speed", 77 },
{ "external_perimeter_speed", 66 },
{ "enable_dynamic_overhang_speeds", false },
{ "bridge_speed", 99 },
{ "cooling", "1" },
{ "fan_below_layer_time", "0" },
@ -530,6 +531,7 @@ SCENARIO("Perimeters3", "[Perimeters]")
{ "perimeters", 3 },
{ "layer_height", 0.4 },
{ "bridge_speed", 99 },
{ "enable_dynamic_overhang_speeds", false },
// to prevent bridging over sparse infill
{ "fill_density", 0 },
{ "overhangs", true },

View file

@ -220,10 +220,16 @@ SCENARIO( "make_xxx functions produce meshes.") {
GIVEN("make_sphere() function") {
WHEN("make_sphere() is called with arguments 10, PI / 3") {
TriangleMesh sph = make_sphere(10, PI / 243.0);
THEN("Resulting mesh has one point at 0,0,-10 and one at 0,0,10") {
const std::vector<stl_vertex> &verts = sph.its.vertices;
REQUIRE(std::count_if(verts.begin(), verts.end(), [](const Vec3f& t) { return is_approx(t, Vec3f(0.f, 0.f, 10.f)); } ) == 1);
REQUIRE(std::count_if(verts.begin(), verts.end(), [](const Vec3f& t) { return is_approx(t, Vec3f(0.f, 0.f, -10.f)); } ) == 1);
THEN( "Edge length is smaller than limit but not smaller than half of it") {
double len = (sph.its.vertices[sph.its.indices[0][0]] - sph.its.vertices[sph.its.indices[0][1]]).norm();
double limit = 10*PI/243.;
REQUIRE(len <= limit);
REQUIRE(len >= limit/2.);
}
THEN( "Vertices are about the correct distance from the origin") {
bool all_vertices_ok = std::all_of(sph.its.vertices.begin(), sph.its.vertices.end(),
[](const stl_vertex& pt) { return is_approx(pt.squaredNorm(), 100.f); });
REQUIRE(all_vertices_ok);
}
THEN( "The mesh volume is approximately 4/3 * pi * 10^3") {
REQUIRE(abs(sph.volume() - (4.0/3.0 * M_PI * std::pow(10,3))) < 1); // 1% tolerance?

View file

@ -414,3 +414,279 @@ TEST_CASE("Arachne - #8597 - removeSmallAreas", "[ArachneRemoveSmallAreas8597]")
REQUIRE(perimeters.size() == 1);
}
// Test case for missing infill that is probably caused by PolylineStitcher, which produced an open polyline.
TEST_CASE("Arachne - Missing infill", "[ArachneMissingInfill]") {
const Polygon poly_0 = {
Point( 5525881, 3649657),
Point( 452351, -2035297),
Point(-1014702, -2144286),
Point(-5142096, -9101108),
Point( 5525882, -9101108),
};
const Polygon poly_1 = {
Point(1415524, -2217520),
Point(1854189, -2113857),
Point(1566974, -2408538),
};
const Polygon poly_2 = {
Point(-42854, -3771357),
Point(310500, -3783332),
Point( 77735, -4059215),
};
Polygons polygons = {poly_0, poly_1, poly_2};
coord_t spacing = 357079;
coord_t inset_count = 2;
Arachne::WallToolPaths wallToolPaths(polygons, spacing, spacing, inset_count, 0, 0.2, PrintObjectConfig::defaults(), PrintConfig::defaults());
wallToolPaths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wallToolPaths.getToolPaths();
#ifdef ARACHNE_DEBUG_OUT
export_perimeters_to_svg(debug_out_path("arachne-missing-infill.svg"), polygons, perimeters, union_ex(wallToolPaths.getInnerContour()));
#endif
// REQUIRE(wallToolPaths.getInnerContour().size() == 1);
}
// This test case was distilled from GitHub issue #8849.
// Missing part of the model after simplifying generated tool-paths by simplifyToolPaths.
TEST_CASE("Arachne - #8849 - Missing part of model", "[ArachneMissingPart8849]") {
const Polygon poly_0 = {
Point(-29700000, -10600000),
Point(-28200000, -10600000),
Point( 20000000, -10600000),
Point( 20000000, - 9900000),
Point(-28200000, - 9900000),
Point(-28200000, 0),
Point(-29700000, 0),
};
Polygons polygons = {poly_0};
coord_t ext_perimeter_spacing = 449999;
coord_t perimeter_spacing = 757079;
coord_t inset_count = 2;
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.32, PrintObjectConfig::defaults(), PrintConfig::defaults());
wall_tool_paths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wall_tool_paths.getToolPaths();
#ifdef ARACHNE_DEBUG_OUT
export_perimeters_to_svg(debug_out_path("arachne-missing-part-8849.svg"), polygons, perimeters, union_ex(wall_tool_paths.getInnerContour()));
#endif
int64_t total_extrusion_length = 0;
for (Arachne::VariableWidthLines &perimeter : perimeters)
for (Arachne::ExtrusionLine &extrusion_line : perimeter)
total_extrusion_length += extrusion_line.getLength();
// Total extrusion length should be around 30mm when the part is missing and around 120 when everything is ok.
// REQUIRE(total_extrusion_length >= scaled<int64_t>(120.));
}
// This test case was distilled from GitHub issue #8446.
// Boost Voronoi generator produces non-planar Voronoi diagram with two intersecting linear Voronoi edges.
// Those intersecting edges are causing that perimeters are also generated in places where they shouldn't be.
TEST_CASE("Arachne - #8446 - Degenerated Voronoi diagram - Linear edges", "[ArachneDegeneratedDiagram8446LinearEdges]") {
Polygon poly_0 = {
Point( 42240656, 9020315),
Point( 4474248, 42960681),
Point( -4474248, 42960681),
Point( -4474248, 23193537),
Point( -6677407, 22661038),
Point( -8830542, 21906307),
Point( -9702935, 21539826),
Point(-13110431, 19607811),
Point(-18105334, 15167780),
Point(-20675743, 11422461),
Point(-39475413, 17530840),
Point(-42240653, 9020315)
};
Polygons polygons = {poly_0};
coord_t ext_perimeter_spacing = 407079;
coord_t perimeter_spacing = 407079;
coord_t inset_count = 1;
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, PrintObjectConfig::defaults(), PrintConfig::defaults());
wall_tool_paths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wall_tool_paths.getToolPaths();
#ifdef ARACHNE_DEBUG_OUT
export_perimeters_to_svg(debug_out_path("arachne-degenerated-diagram-8446-linear-edges.svg"), polygons, perimeters, union_ex(wall_tool_paths.getInnerContour()));
#endif
int64_t total_extrusion_length = 0;
for (Arachne::VariableWidthLines &perimeter : perimeters)
for (Arachne::ExtrusionLine &extrusion_line : perimeter)
total_extrusion_length += extrusion_line.getLength();
// Total extrusion length should be around 211.2mm when the part is ok and 212.1mm when it has perimeters in places where they shouldn't be.
REQUIRE(total_extrusion_length <= scaled<int64_t>(211.5));
}
// This test case was distilled from GitHub issue #8846.
// Boost Voronoi generator produces degenerated Voronoi diagram with one parabolic edge intersecting linear Voronoi edge.
// Those intersecting edges are causing that perimeters are also generated in places where they shouldn't be.
TEST_CASE("Arachne - #8846 - Degenerated Voronoi diagram - One Parabola", "[ArachneDegeneratedDiagram8846OneParabola]") {
const Polygon poly_0 = {
Point(101978540, -41304489), Point(101978540, 41304489),
Point(94709788, 42514051), Point(94709788, 48052315),
Point(93352716, 48052315), Point(93352716, 42514052),
Point(75903540, 42514051), Point(75903540, 48052315),
Point(74546460, 48052315), Point(74546460, 42514052),
Point(69634788, 42514051), Point(69634788, 48052315),
Point(68277708, 48052315), Point(68277708, 42514051),
Point(63366040, 42514051), Point(63366040, 48052315),
Point(62008960, 48052315), Point(62008960, 42514051),
Point(57097292, 42514051), Point(57097292, 48052315),
Point(55740212, 48052315), Point(55740212, 42514052),
Point(50828540, 42514052), Point(50828540, 48052315),
Point(49471460, 48052315), Point(49471460, 42514051),
Point(25753540, 42514051), Point(25753540, 48052315),
Point(24396460, 48052315), Point(24396460, 42514051),
Point(19484790, 42514052), Point(19484790, 48052315),
Point(18127710, 48052315), Point(18127710, 42514051),
Point(-5590210, 42514051), Point(-5590210, 48052315),
Point(-6947290, 48052315), Point(-6947290, 42514051),
Point(-11858960, 42514051), Point(-11858960, 48052315),
Point(-13216040, 48052315), Point(-13216040, 42514051),
Point(-18127710, 42514051), Point(-18127710, 48052315),
Point(-19484790, 48052315), Point(-19484790, 42514052),
Point(-49471460, 42514051), Point(-49471460, 48052315),
Point(-50828540, 48052315), Point(-50828540, 42514052),
Point(-55740212, 42514052), Point(-55740212, 48052315),
Point(-57097292, 48052315), Point(-57097292, 42514051),
Point(-68277708, 42514051), Point(-68277708, 48052315),
Point(-69634788, 48052315), Point(-69634788, 42514051),
Point(-74546460, 42514052), Point(-74546460, 48052315),
Point(-75903540, 48052315), Point(-75903540, 42514051),
Point(-80815204, 42514051), Point(-80815204, 48052315),
Point(-82172292, 48052315), Point(-82172292, 42514051),
Point(-87083956, 42514051), Point(-87083956, 48052315),
Point(-88441044, 48052315), Point(-88441044, 42514051),
Point(-99621460, 42514051), Point(-99621460, 48052315),
Point(-100978540, 48052315), Point(-100978540, 42528248),
Point(-101978540, 41304489), Point(-101978540, -41304489),
Point(-100978540, -48052315), Point(-99621460, -48052315),
};
Polygon poly_1 = {
Point(-100671460, -40092775),
Point(-100671460, 40092775),
Point(100671460, 40092775),
Point(100671460, -40092775),
};
Polygons polygons = {poly_0, poly_1};
coord_t ext_perimeter_spacing = 607079;
coord_t perimeter_spacing = 607079;
coord_t inset_count = 1;
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, PrintObjectConfig::defaults(), PrintConfig::defaults());
wall_tool_paths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wall_tool_paths.getToolPaths();
#ifdef ARACHNE_DEBUG_OUT
export_perimeters_to_svg(debug_out_path("arachne-degenerated-diagram-8846-one-parabola.svg"), polygons, perimeters, union_ex(wall_tool_paths.getInnerContour()));
#endif
int64_t total_extrusion_length = 0;
for (Arachne::VariableWidthLines &perimeter : perimeters)
for (Arachne::ExtrusionLine &extrusion_line : perimeter)
total_extrusion_length += extrusion_line.getLength();
// Total extrusion length should be around 1335mm when the part is ok and 1347mm when it has perimeters in places where they shouldn't be.
REQUIRE(total_extrusion_length <= scaled<int64_t>(1335.));
}
// This test case was distilled from GitHub issue #9357.
// Boost Voronoi generator produces degenerated Voronoi diagram with two intersecting parabolic Voronoi edges.
// Those intersecting edges are causing that perimeters are also generated in places where they shouldn't be.
TEST_CASE("Arachne - #9357 - Degenerated Voronoi diagram - Two parabolas", "[ArachneDegeneratedDiagram9357TwoParabolas]") {
const Polygon poly_0 = {
Point(78998946, -11733905),
Point(40069507, -7401251),
Point(39983905, -6751055),
Point(39983905, 8251054),
Point(79750000, 10522762),
Point(79983905, 10756667),
Point(79983905, 12248946),
Point(79950248, 12504617),
Point(79709032, 12928156),
Point(79491729, 13102031),
Point(78998946, 13233905),
Point(38501054, 13233905),
Point(37258117, 12901005),
Point(36349000, 11991885),
Point(36100868, 11392844),
Point(36016095, 10748947),
Point(36016095, -6751054),
Point(35930493, -7401249),
Point(4685798, -11733905),
};
Polygons polygons = {poly_0};
coord_t ext_perimeter_spacing = 407079;
coord_t perimeter_spacing = 407079;
coord_t inset_count = 1;
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, PrintObjectConfig::defaults(), PrintConfig::defaults());
wall_tool_paths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wall_tool_paths.getToolPaths();
#ifdef ARACHNE_DEBUG_OUT
export_perimeters_to_svg(debug_out_path("arachne-degenerated-diagram-9357-two-parabolas.svg"), polygons, perimeters, union_ex(wall_tool_paths.getInnerContour()));
#endif
int64_t total_extrusion_length = 0;
for (Arachne::VariableWidthLines &perimeter : perimeters)
for (Arachne::ExtrusionLine &extrusion_line : perimeter)
total_extrusion_length += extrusion_line.getLength();
// Total extrusion length should be around 256mm when the part is ok and 293mm when it has perimeters in places where they shouldn't be.
REQUIRE(total_extrusion_length <= scaled<int64_t>(256.));
}
// This test case was distilled from GitHub issue #8846.
// Boost Voronoi generator produces degenerated Voronoi diagram with some Voronoi edges intersecting input segments.
// Those Voronoi edges intersecting input segments are causing that perimeters are also generated in places where they shouldn't be.
TEST_CASE("Arachne - #8846 - Degenerated Voronoi diagram - Voronoi edges intersecting input segment", "[ArachneDegeneratedDiagram8846IntersectingInputSegment]") {
const Polygon poly_0 = {
Point( 60000000, 58000000),
Point(-20000000, 53229451),
Point( 49312250, 53229452),
Point( 49443687, 53666225),
Point( 55358348, 50908580),
Point( 53666223, 49443687),
Point( 53229452, 49312250),
Point( 53229452, -49312250),
Point( 53666014, -49443623),
Point(-10000000, -58000000),
Point( 60000000, -58000000),
};
Polygons polygons = {poly_0};
coord_t ext_perimeter_spacing = 407079;
coord_t perimeter_spacing = 407079;
coord_t inset_count = 1;
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.32, PrintObjectConfig::defaults(), PrintConfig::defaults());
wall_tool_paths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wall_tool_paths.getToolPaths();
#ifdef ARACHNE_DEBUG_OUT
export_perimeters_to_svg(debug_out_path("arachne-degenerated-diagram-8846-intersecting-input-segment.svg"), polygons, perimeters, union_ex(wall_tool_paths.getInnerContour()));
#endif
int64_t total_extrusion_length = 0;
for (Arachne::VariableWidthLines &perimeter : perimeters)
for (Arachne::ExtrusionLine &extrusion_line : perimeter)
total_extrusion_length += extrusion_line.getLength();
// Total extrusion length should be around 500mm when the part is ok and 680mm when it has perimeters in places where they shouldn't be.
REQUIRE(total_extrusion_length <= scaled<int64_t>(500.));
}

View file

@ -201,7 +201,7 @@ ExPolygons heal_and_check(const Polygons &polygons)
{
Pointfs intersections_prev = intersection_points(polygons);
Points polygons_points = to_points(polygons);
Points duplicits_prev = collect_duplications(polygons_points);
Points duplicits_prev = collect_duplicates(polygons_points);
ExPolygons shape = Emboss::heal_shape(polygons);
@ -215,7 +215,7 @@ ExPolygons heal_and_check(const Polygons &polygons)
Pointfs intersections = intersection_points(shape);
Points shape_points = to_points(shape);
Points duplicits = collect_duplications(shape_points);
Points duplicits = collect_duplicates(shape_points);
//{
// BoundingBox bb(polygons_points);
// // bb.scale(svg_scale);
@ -377,22 +377,30 @@ TEST_CASE("triangle intersection", "[]")
CHECK(abs(i.y() - 1.) < std::numeric_limits<double>::epsilon());
}
#ifndef __APPLE__
#if defined _WIN32
#define FONT_DIR_PATH "C:/Windows/Fonts";
#endif
//#elif defined __linux__
//#define FONT_DIR_PATH "/usr/share/fonts";
//#elif defined __APPLE__
//#define FONT_DIR_PATH "//System/Library/Fonts";
//#endif
#ifdef FONT_DIR_PATH
#include <string>
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
//#include <filesystem>
//namespace fs = std::filesystem;
// Check function Emboss::is_italic that exist some italic and some non-italic font.
TEST_CASE("Italic check", "[Emboss]")
{
std::string dir_path = FONT_DIR_PATH;
std::queue<std::string> dir_paths;
#ifdef _WIN32
dir_paths.push("C:/Windows/Fonts");
#elif defined(__linux__)
dir_paths.push("/usr/share/fonts");
//#elif defined(__APPLE__)
// dir_paths.push("//System/Library/Fonts");
#endif
dir_paths.push(dir_path);
bool exist_italic = false;
bool exist_non_italic = false;
while (!dir_paths.empty()) {
@ -400,15 +408,15 @@ TEST_CASE("Italic check", "[Emboss]")
dir_paths.pop();
for (const auto &entry : fs::directory_iterator(dir_path)) {
const fs::path &act_path = entry.path();
if (entry.is_directory()) {
dir_paths.push(act_path.u8string());
if (fs::is_directory(entry)) {
dir_paths.push(act_path.string());
continue;
}
std::string ext = act_path.extension().u8string();
std::string ext = act_path.extension().string();
std::transform(ext.begin(), ext.end(), ext.begin(),
[](unsigned char c) { return std::tolower(c); });
if (ext != ".ttf") continue;
std::string path_str = act_path.u8string();
std::string path_str = act_path.string();
auto font_opt = Emboss::create_font_file(path_str.c_str());
if (font_opt == nullptr) continue;
@ -425,7 +433,7 @@ TEST_CASE("Italic check", "[Emboss]")
CHECK(exist_italic);
CHECK(exist_non_italic);
}
#endif // not __APPLE__
#endif // FONT_DIR_PATH
#include "libslic3r/CutSurface.hpp"
TEST_CASE("Cut surface", "[]")

View file

@ -282,8 +282,22 @@ static void _test_concave_hull(const Polygons &hull, const ExPolygons &polys)
REQUIRE(cchull_holes == 0);
Polygons intr = diff(to_polygons(polys), hull);
REQUIRE(intr.empty());
Polygons diff_poly = diff(to_polygons(polys), hull);
if (!diff_poly.empty()) {
BOOST_LOG_TRIVIAL(warning)
<< "Concave hull diff with original shape is not completely empty."
<< "See pad_chull.svg for details.";
SVG svg("pad_chull.svg");
svg.draw(polys, "green");
svg.draw(hull, "red");
svg.draw(diff_poly, "blue");
}
double diff_area = area(diff_poly);
REQUIRE(std::abs(diff_area) < std::pow(scaled(2 * EPSILON), 2));
}
void test_concave_hull(const ExPolygons &polys) {