From 070070edba9827eb4422f1cf40c93b302f60855b Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 18 Oct 2019 13:05:22 +0200 Subject: [PATCH 1/4] Initial tests for import of ASCII STLs with varying line endings. --- tests/data/test_stl/ASCII/20mmbox-CR.stl | 1 + tests/data/test_stl/ASCII/20mmbox-CRLF.stl | 86 ++++++++++++++++++ tests/data/test_stl/ASCII/20mmbox-LF.stl | 86 ++++++++++++++++++ tests/data/test_stl/Geräte/20mmbox-čřšřěá.stl | Bin 0 -> 684 bytes tests/libslic3r/CMakeLists.txt | 1 + tests/libslic3r/test_3mf.cpp | 2 +- tests/libslic3r/test_stl.cpp | 49 ++++++++++ 7 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 tests/data/test_stl/ASCII/20mmbox-CR.stl create mode 100644 tests/data/test_stl/ASCII/20mmbox-CRLF.stl create mode 100644 tests/data/test_stl/ASCII/20mmbox-LF.stl create mode 100644 tests/data/test_stl/Geräte/20mmbox-čřšřěá.stl create mode 100644 tests/libslic3r/test_stl.cpp diff --git a/tests/data/test_stl/ASCII/20mmbox-CR.stl b/tests/data/test_stl/ASCII/20mmbox-CR.stl new file mode 100644 index 000000000..53c85bb28 --- /dev/null +++ b/tests/data/test_stl/ASCII/20mmbox-CR.stl @@ -0,0 +1 @@ +solid STL generated by MeshLab facet normal 0.000000e+00 -0.000000e+00 -1.000000e+00 outer loop vertex 2.000000e+01 2.000000e+01 0.000000e+00 vertex 2.000000e+01 0.000000e+00 0.000000e+00 vertex 0.000000e+00 0.000000e+00 0.000000e+00 endloop endfacet facet normal -0.000000e+00 0.000000e+00 -1.000000e+00 outer loop vertex 2.000000e+01 2.000000e+01 0.000000e+00 vertex 0.000000e+00 0.000000e+00 0.000000e+00 vertex 0.000000e+00 2.000000e+01 0.000000e+00 endloop endfacet facet normal 0.000000e+00 0.000000e+00 1.000000e+00 outer loop vertex 2.000000e+01 2.000000e+01 2.000000e+01 vertex 0.000000e+00 2.000000e+01 2.000000e+01 vertex 0.000000e+00 0.000000e+00 2.000000e+01 endloop endfacet facet normal 0.000000e+00 0.000000e+00 1.000000e+00 outer loop vertex 2.000000e+01 2.000000e+01 2.000000e+01 vertex 0.000000e+00 0.000000e+00 2.000000e+01 vertex 2.000000e+01 0.000000e+00 2.000000e+01 endloop endfacet facet normal 1.000000e+00 0.000000e+00 -0.000000e+00 outer loop vertex 2.000000e+01 2.000000e+01 0.000000e+00 vertex 2.000000e+01 2.000000e+01 2.000000e+01 vertex 2.000000e+01 0.000000e+00 2.000000e+01 endloop endfacet facet normal 1.000000e+00 0.000000e+00 0.000000e+00 outer loop vertex 2.000000e+01 2.000000e+01 0.000000e+00 vertex 2.000000e+01 0.000000e+00 2.000000e+01 vertex 2.000000e+01 0.000000e+00 0.000000e+00 endloop endfacet facet normal 0.000000e+00 -1.000000e+00 0.000000e+00 outer loop vertex 2.000000e+01 0.000000e+00 0.000000e+00 vertex 2.000000e+01 0.000000e+00 2.000000e+01 vertex 0.000000e+00 0.000000e+00 2.000000e+01 endloop endfacet facet normal 0.000000e+00 -1.000000e+00 0.000000e+00 outer loop vertex 2.000000e+01 0.000000e+00 0.000000e+00 vertex 0.000000e+00 0.000000e+00 2.000000e+01 vertex 0.000000e+00 0.000000e+00 0.000000e+00 endloop endfacet facet normal -1.000000e+00 0.000000e+00 0.000000e+00 outer loop vertex 0.000000e+00 0.000000e+00 0.000000e+00 vertex 0.000000e+00 0.000000e+00 2.000000e+01 vertex 0.000000e+00 2.000000e+01 2.000000e+01 endloop endfacet facet normal -1.000000e+00 0.000000e+00 0.000000e+00 outer loop vertex 0.000000e+00 0.000000e+00 0.000000e+00 vertex 0.000000e+00 2.000000e+01 2.000000e+01 vertex 0.000000e+00 2.000000e+01 0.000000e+00 endloop endfacet facet normal 0.000000e+00 1.000000e+00 0.000000e+00 outer loop vertex 2.000000e+01 2.000000e+01 2.000000e+01 vertex 2.000000e+01 2.000000e+01 0.000000e+00 vertex 0.000000e+00 2.000000e+01 0.000000e+00 endloop endfacet facet normal 0.000000e+00 1.000000e+00 0.000000e+00 outer loop vertex 2.000000e+01 2.000000e+01 2.000000e+01 vertex 0.000000e+00 2.000000e+01 0.000000e+00 vertex 0.000000e+00 2.000000e+01 2.000000e+01 endloop endfacet endsolid vcg \ No newline at end of file diff --git a/tests/data/test_stl/ASCII/20mmbox-CRLF.stl b/tests/data/test_stl/ASCII/20mmbox-CRLF.stl new file mode 100644 index 000000000..fb6e065a7 --- /dev/null +++ b/tests/data/test_stl/ASCII/20mmbox-CRLF.stl @@ -0,0 +1,86 @@ +solid STL generated by MeshLab + facet normal 0.000000e+00 -0.000000e+00 -1.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 0.000000e+00 + vertex 2.000000e+01 0.000000e+00 0.000000e+00 + vertex 0.000000e+00 0.000000e+00 0.000000e+00 + endloop + endfacet + facet normal -0.000000e+00 0.000000e+00 -1.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 0.000000e+00 + vertex 0.000000e+00 0.000000e+00 0.000000e+00 + vertex 0.000000e+00 2.000000e+01 0.000000e+00 + endloop + endfacet + facet normal 0.000000e+00 0.000000e+00 1.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 2.000000e+01 + vertex 0.000000e+00 2.000000e+01 2.000000e+01 + vertex 0.000000e+00 0.000000e+00 2.000000e+01 + endloop + endfacet + facet normal 0.000000e+00 0.000000e+00 1.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 2.000000e+01 + vertex 0.000000e+00 0.000000e+00 2.000000e+01 + vertex 2.000000e+01 0.000000e+00 2.000000e+01 + endloop + endfacet + facet normal 1.000000e+00 0.000000e+00 -0.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 0.000000e+00 + vertex 2.000000e+01 2.000000e+01 2.000000e+01 + vertex 2.000000e+01 0.000000e+00 2.000000e+01 + endloop + endfacet + facet normal 1.000000e+00 0.000000e+00 0.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 0.000000e+00 + vertex 2.000000e+01 0.000000e+00 2.000000e+01 + vertex 2.000000e+01 0.000000e+00 0.000000e+00 + endloop + endfacet + facet normal 0.000000e+00 -1.000000e+00 0.000000e+00 + outer loop + vertex 2.000000e+01 0.000000e+00 0.000000e+00 + vertex 2.000000e+01 0.000000e+00 2.000000e+01 + vertex 0.000000e+00 0.000000e+00 2.000000e+01 + endloop + endfacet + facet normal 0.000000e+00 -1.000000e+00 0.000000e+00 + outer loop + vertex 2.000000e+01 0.000000e+00 0.000000e+00 + vertex 0.000000e+00 0.000000e+00 2.000000e+01 + vertex 0.000000e+00 0.000000e+00 0.000000e+00 + endloop + endfacet + facet normal -1.000000e+00 0.000000e+00 0.000000e+00 + outer loop + vertex 0.000000e+00 0.000000e+00 0.000000e+00 + vertex 0.000000e+00 0.000000e+00 2.000000e+01 + vertex 0.000000e+00 2.000000e+01 2.000000e+01 + endloop + endfacet + facet normal -1.000000e+00 0.000000e+00 0.000000e+00 + outer loop + vertex 0.000000e+00 0.000000e+00 0.000000e+00 + vertex 0.000000e+00 2.000000e+01 2.000000e+01 + vertex 0.000000e+00 2.000000e+01 0.000000e+00 + endloop + endfacet + facet normal 0.000000e+00 1.000000e+00 0.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 2.000000e+01 + vertex 2.000000e+01 2.000000e+01 0.000000e+00 + vertex 0.000000e+00 2.000000e+01 0.000000e+00 + endloop + endfacet + facet normal 0.000000e+00 1.000000e+00 0.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 2.000000e+01 + vertex 0.000000e+00 2.000000e+01 0.000000e+00 + vertex 0.000000e+00 2.000000e+01 2.000000e+01 + endloop + endfacet +endsolid vcg diff --git a/tests/data/test_stl/ASCII/20mmbox-LF.stl b/tests/data/test_stl/ASCII/20mmbox-LF.stl new file mode 100644 index 000000000..fb6e065a7 --- /dev/null +++ b/tests/data/test_stl/ASCII/20mmbox-LF.stl @@ -0,0 +1,86 @@ +solid STL generated by MeshLab + facet normal 0.000000e+00 -0.000000e+00 -1.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 0.000000e+00 + vertex 2.000000e+01 0.000000e+00 0.000000e+00 + vertex 0.000000e+00 0.000000e+00 0.000000e+00 + endloop + endfacet + facet normal -0.000000e+00 0.000000e+00 -1.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 0.000000e+00 + vertex 0.000000e+00 0.000000e+00 0.000000e+00 + vertex 0.000000e+00 2.000000e+01 0.000000e+00 + endloop + endfacet + facet normal 0.000000e+00 0.000000e+00 1.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 2.000000e+01 + vertex 0.000000e+00 2.000000e+01 2.000000e+01 + vertex 0.000000e+00 0.000000e+00 2.000000e+01 + endloop + endfacet + facet normal 0.000000e+00 0.000000e+00 1.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 2.000000e+01 + vertex 0.000000e+00 0.000000e+00 2.000000e+01 + vertex 2.000000e+01 0.000000e+00 2.000000e+01 + endloop + endfacet + facet normal 1.000000e+00 0.000000e+00 -0.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 0.000000e+00 + vertex 2.000000e+01 2.000000e+01 2.000000e+01 + vertex 2.000000e+01 0.000000e+00 2.000000e+01 + endloop + endfacet + facet normal 1.000000e+00 0.000000e+00 0.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 0.000000e+00 + vertex 2.000000e+01 0.000000e+00 2.000000e+01 + vertex 2.000000e+01 0.000000e+00 0.000000e+00 + endloop + endfacet + facet normal 0.000000e+00 -1.000000e+00 0.000000e+00 + outer loop + vertex 2.000000e+01 0.000000e+00 0.000000e+00 + vertex 2.000000e+01 0.000000e+00 2.000000e+01 + vertex 0.000000e+00 0.000000e+00 2.000000e+01 + endloop + endfacet + facet normal 0.000000e+00 -1.000000e+00 0.000000e+00 + outer loop + vertex 2.000000e+01 0.000000e+00 0.000000e+00 + vertex 0.000000e+00 0.000000e+00 2.000000e+01 + vertex 0.000000e+00 0.000000e+00 0.000000e+00 + endloop + endfacet + facet normal -1.000000e+00 0.000000e+00 0.000000e+00 + outer loop + vertex 0.000000e+00 0.000000e+00 0.000000e+00 + vertex 0.000000e+00 0.000000e+00 2.000000e+01 + vertex 0.000000e+00 2.000000e+01 2.000000e+01 + endloop + endfacet + facet normal -1.000000e+00 0.000000e+00 0.000000e+00 + outer loop + vertex 0.000000e+00 0.000000e+00 0.000000e+00 + vertex 0.000000e+00 2.000000e+01 2.000000e+01 + vertex 0.000000e+00 2.000000e+01 0.000000e+00 + endloop + endfacet + facet normal 0.000000e+00 1.000000e+00 0.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 2.000000e+01 + vertex 2.000000e+01 2.000000e+01 0.000000e+00 + vertex 0.000000e+00 2.000000e+01 0.000000e+00 + endloop + endfacet + facet normal 0.000000e+00 1.000000e+00 0.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 2.000000e+01 + vertex 0.000000e+00 2.000000e+01 0.000000e+00 + vertex 0.000000e+00 2.000000e+01 2.000000e+01 + endloop + endfacet +endsolid vcg diff --git a/tests/data/test_stl/Geräte/20mmbox-čřšřěá.stl b/tests/data/test_stl/Geräte/20mmbox-čřšřěá.stl new file mode 100644 index 0000000000000000000000000000000000000000..0ffc0d8901fb3526023099e803e6086a35f6c60a GIT binary patch literal 684 zcmb`D;SGgA2!k2GonG9GQQYLMrnP>7oTtBRV&F(?IQlTb~>rwQI#`(Nv4$ZoXlpT1eJof+q literal 0 HcmV?d00001 diff --git a/tests/libslic3r/CMakeLists.txt b/tests/libslic3r/CMakeLists.txt index e6f04d282..2dd2b34a3 100644 --- a/tests/libslic3r/CMakeLists.txt +++ b/tests/libslic3r/CMakeLists.txt @@ -5,6 +5,7 @@ add_executable(${_TEST_NAME}_tests test_config.cpp test_geometry.cpp test_polygon.cpp + test_stl.cpp ) target_link_libraries(${_TEST_NAME}_tests test_common libslic3r) set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests") diff --git a/tests/libslic3r/test_3mf.cpp b/tests/libslic3r/test_3mf.cpp index 0cde0b0dc..b413cbe0b 100644 --- a/tests/libslic3r/test_3mf.cpp +++ b/tests/libslic3r/test_3mf.cpp @@ -5,7 +5,7 @@ using namespace Slic3r; -SCENARIO("Reading 3mf file") { +SCENARIO("Reading 3mf file", "[3mf]") { GIVEN("umlauts in the path of the file") { Slic3r::Model model; WHEN("3mf model is read") { diff --git a/tests/libslic3r/test_stl.cpp b/tests/libslic3r/test_stl.cpp new file mode 100644 index 000000000..f64f8243f --- /dev/null +++ b/tests/libslic3r/test_stl.cpp @@ -0,0 +1,49 @@ +#include + +#include "libslic3r/Model.hpp" +#include "libslic3r/Format/STL.hpp" + +using namespace Slic3r; + +static inline std::string stl_path(const char* path) +{ + return std::string(TEST_DATA_DIR) + "/test_stl/" + path; +} + +SCENARIO("Reading an STL file", "[stl]") { + GIVEN("umlauts in the path of a binary STL file, Czech characters in the file name") { + WHEN("STL file is read") { + Slic3r::Model model; + THEN("load should succeed") { + REQUIRE(Slic3r::load_stl(stl_path("Geräte/20mmbox-čřšřěá.stl").c_str(), &model)); + REQUIRE(is_approx(model.objects.front()->volumes.front()->mesh().size(), Vec3d(20, 20, 20))); + } + } + } + GIVEN("in ASCII format") { + WHEN("line endings LF") { + Slic3r::Model model; + THEN("load should succeed") { + REQUIRE(Slic3r::load_stl(stl_path("ASCII/20mmbox-LF.stl").c_str(), &model)); + REQUIRE(is_approx(model.objects.front()->volumes.front()->mesh().size(), Vec3d(20, 20, 20))); + } + } + WHEN("line endings CRLF") { + Slic3r::Model model; + THEN("load should succeed") { + REQUIRE(Slic3r::load_stl(stl_path("ASCII/20mmbox-CRLF.stl").c_str(), &model)); + REQUIRE(is_approx(model.objects.front()->volumes.front()->mesh().size(), Vec3d(20, 20, 20))); + } + } +#if 0 + // ASCII STLs ending with just carriage returns are not supported. These were used by the old Macs, while the Unix based MacOS uses LFs as any other Unix. + WHEN("line endings CR") { + Slic3r::Model model; + THEN("load should succeed") { + REQUIRE(Slic3r::load_stl(stl_path("ASCII/20mmbox-CR.stl").c_str(), &model)); + REQUIRE(is_approx(model.objects.front()->volumes.front()->mesh().size(), Vec3d(20, 20, 20))); + } + } +#endif + } +} From 6e6b137151f63a6c6bc89a7f5c5875fc73784819 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 18 Oct 2019 14:42:03 +0200 Subject: [PATCH 2/4] Test of importing non-standard ASCII STL (broken normals, junk after the ending tags) --- tests/data/test_stl/ASCII/20mmbox-LF.stl | 2 +- .../test_stl/ASCII/20mmbox-nonstandard.stl | 86 +++++++++++++++++++ tests/libslic3r/test_stl.cpp | 8 ++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 tests/data/test_stl/ASCII/20mmbox-nonstandard.stl diff --git a/tests/data/test_stl/ASCII/20mmbox-LF.stl b/tests/data/test_stl/ASCII/20mmbox-LF.stl index fb6e065a7..1cb892b74 100644 --- a/tests/data/test_stl/ASCII/20mmbox-LF.stl +++ b/tests/data/test_stl/ASCII/20mmbox-LF.stl @@ -83,4 +83,4 @@ solid STL generated by MeshLab vertex 0.000000e+00 2.000000e+01 2.000000e+01 endloop endfacet -endsolid vcg +endsolid diff --git a/tests/data/test_stl/ASCII/20mmbox-nonstandard.stl b/tests/data/test_stl/ASCII/20mmbox-nonstandard.stl new file mode 100644 index 000000000..1e3bcc489 --- /dev/null +++ b/tests/data/test_stl/ASCII/20mmbox-nonstandard.stl @@ -0,0 +1,86 @@ +solid STL generated by MeshLab + facet normal 0.000000e+00 -0.000000e+00 -1.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 0.000000e+00 + vertex 2.000000e+01 0.000000e+00 0.000000e+00 + vertex 0.000000e+00 0.000000e+00 0.000000e+00 + endloop + endfacet + facet normal -0.000000e+00 0.000000e+00 -1.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 0.000000e+00 + vertex 0.000000e+00 0.000000e+00 0.000000e+00 + vertex 0.000000e+00 2.000000e+01 0.000000e+00 + endloop + endfacet + facet normal 0.000000e+00 0.000000e+00 1.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 2.000000e+01 + vertex 0.000000e+00 2.000000e+01 2.000000e+01 + vertex 0.000000e+00 0.000000e+00 2.000000e+01 + endloop + endfacet + facet normal 0.000000e+00 0.000000e+00 1.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 2.000000e+01 + vertex 0.000000e+00 0.000000e+00 2.000000e+01 + vertex 2.000000e+01 0.000000e+00 2.000000e+01 + endloop + endfacet + facet normal 1.000000e+00 0.000000e+00 -0.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 0.000000e+00 + vertex 2.000000e+01 2.000000e+01 2.000000e+01 + vertex 2.000000e+01 0.000000e+00 2.000000e+01 + endloop + endfacet + facet normal 1.000000e+00 0.000000e+00 0.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 0.000000e+00 + vertex 2.000000e+01 0.000000e+00 2.000000e+01 + vertex 2.000000e+01 0.000000e+00 0.000000e+00 + endloop + endfacet + facet normal 0.000000e+00 -1.000000e+00 0.000000e+00 + outer loop + vertex 2.000000e+01 0.000000e+00 0.000000e+00 + vertex 2.000000e+01 0.000000e+00 2.000000e+01 + vertex 0.000000e+00 0.000000e+00 2.000000e+01 + endloop + endfacet + facet normal 0.000000e+00 -1.000000e+00 0.000000e+00 + outer loop + vertex 2.000000e+01 0.000000e+00 0.000000e+00 + vertex 0.000000e+00 0.000000e+00 2.000000e+01 + vertex 0.000000e+00 0.000000e+00 0.000000e+00 + endloop + endfacet + facet normal +inf -inf weirdvalue + outer loop + vertex 0.000000e+00 0.000000e+00 0.000000e+00 + vertex 0.000000e+00 0.000000e+00 2.000000e+01 + vertex 0.000000e+00 2.000000e+01 2.000000e+01 + endloop + endfacet + facet normal -1.000000e+00 0.000000e+00 0.000000e+00 + outer loop + vertex 0.000000e+00 0.000000e+00 0.000000e+00 + vertex 0.000000e+00 2.000000e+01 2.000000e+01 + vertex 0.000000e+00 2.000000e+01 0.000000e+00 + endloop + endfacet blah + facet normal 0.000000e+00 1.000000e+00 0.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 2.000000e+01 + vertex 2.000000e+01 2.000000e+01 0.000000e+00 + vertex 0.000000e+00 2.000000e+01 0.000000e+00 + endloop foo + endfacet bar + facet normal 0.000000e+00 1.000000e+00 0.000000e+00 + outer loop + vertex 2.000000e+01 2.000000e+01 2.000000e+01 + vertex 0.000000e+00 2.000000e+01 0.000000e+00 + vertex 0.000000e+00 2.000000e+01 2.000000e+01 + endloop foo + endfacet bar +endsolid some blah blah diff --git a/tests/libslic3r/test_stl.cpp b/tests/libslic3r/test_stl.cpp index f64f8243f..4c9c1bcbb 100644 --- a/tests/libslic3r/test_stl.cpp +++ b/tests/libslic3r/test_stl.cpp @@ -44,6 +44,14 @@ SCENARIO("Reading an STL file", "[stl]") { REQUIRE(is_approx(model.objects.front()->volumes.front()->mesh().size(), Vec3d(20, 20, 20))); } } + #endif + WHEN("nonstandard STL file (text after ending tags, invalid normals, for example infinities)") { + Slic3r::Model model; + THEN("load should succeed") { + REQUIRE(Slic3r::load_stl(stl_path("ASCII/20mmbox-nonstandard.stl").c_str(), &model)); + REQUIRE(is_approx(model.objects.front()->volumes.front()->mesh().size(), Vec3d(20, 20, 20))); + } + } } } From d1a86e513c31b6a005d4e34599c660e3b58fe146 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 18 Oct 2019 15:44:13 +0200 Subject: [PATCH 3/4] Fixing some GCodeExport and Flow unit tests. --- tests/fff_print/test_flow.cpp | 59 ++++++++++++++-------------- tests/fff_print/test_gcodewriter.cpp | 34 ++-------------- 2 files changed, 32 insertions(+), 61 deletions(-) diff --git a/tests/fff_print/test_flow.cpp b/tests/fff_print/test_flow.cpp index dc14d96ee..4541868dc 100644 --- a/tests/fff_print/test_flow.cpp +++ b/tests/fff_print/test_flow.cpp @@ -15,7 +15,7 @@ using namespace Slic3r::Test; using namespace Slic3r; -SCENARIO("Extrusion width specifics", "[!mayfail]") { +SCENARIO("Extrusion width specifics", "[Flow]") { GIVEN("A config with a skirt, brim, some fill density, 3 perimeters, and 1 bottom solid layer and a 20mm cube mesh") { // this is a sharedptr DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config(); @@ -59,7 +59,7 @@ SCENARIO("Extrusion width specifics", "[!mayfail]") { } } // needs gcode export -SCENARIO(" Bridge flow specifics.", "[!mayfail]") { +SCENARIO(" Bridge flow specifics.", "[Flow]") { GIVEN("A default config with no cooling and a fixed bridge speed, flow ratio and an overhang mesh.") { WHEN("bridge_flow_ratio is set to 1.0") { THEN("Output flow is as expected.") { @@ -92,54 +92,53 @@ SCENARIO(" Bridge flow specifics.", "[!mayfail]") { /// Test the expected behavior for auto-width, /// spacing, etc -SCENARIO("Flow: Flow math for non-bridges", "[!mayfail]") { +SCENARIO("Flow: Flow math for non-bridges", "[Flow]") { GIVEN("Nozzle Diameter of 0.4, a desired width of 1mm and layer height of 0.5") { - ConfigOptionFloatOrPercent width(1.0, false); - float spacing {0.4}; - float nozzle_diameter {0.4}; - float bridge_flow {1.0}; - float layer_height {0.5}; + ConfigOptionFloatOrPercent width(1.0, false); + float spacing = 0.4f; + float nozzle_diameter = 0.4f; + float bridge_flow = 0.f; + float layer_height = 0.5f; // Spacing for non-bridges is has some overlap - THEN("External perimeter flow has spacing fixed to 1.1*nozzle_diameter") { - auto flow = Flow::new_from_config_width(frExternalPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, 0.0f); - REQUIRE(flow.spacing() == Approx((1.1*nozzle_diameter) - layer_height * (1.0 - PI / 4.0))); + THEN("External perimeter flow has spacing fixed to 1.125 * nozzle_diameter") { + auto flow = Flow::new_from_config_width(frExternalPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, bridge_flow); + REQUIRE(flow.spacing() == Approx(1.125 * nozzle_diameter - layer_height * (1.0 - PI / 4.0))); } - THEN("Internal perimeter flow has spacing of 1.05 (minimum)") { - auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, 0.0f); - REQUIRE(flow.spacing() == Approx((1.05*nozzle_diameter) - layer_height * (1.0 - PI / 4.0))); + THEN("Internal perimeter flow has spacing fixed to 1.125 * nozzle_diameter") { + auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, bridge_flow); + REQUIRE(flow.spacing() == Approx(1.125 *nozzle_diameter - layer_height * (1.0 - PI / 4.0))); } THEN("Spacing for supplied width is 0.8927f") { - auto flow = Flow::new_from_config_width(frExternalPerimeter, width, nozzle_diameter, layer_height, 0.0f); + auto flow = Flow::new_from_config_width(frExternalPerimeter, width, nozzle_diameter, layer_height, bridge_flow); REQUIRE(flow.spacing() == Approx(width.value - layer_height * (1.0 - PI / 4.0))); - flow = Flow::new_from_config_width(frPerimeter, width, nozzle_diameter, layer_height, 0.0f); + flow = Flow::new_from_config_width(frPerimeter, width, nozzle_diameter, layer_height, bridge_flow); REQUIRE(flow.spacing() == Approx(width.value - layer_height * (1.0 - PI / 4.0))); } } /// Check the min/max GIVEN("Nozzle Diameter of 0.25") { - float spacing {0.4}; - float nozzle_diameter {0.25}; - float bridge_flow {0.0}; - float layer_height {0.5}; + float spacing = 0.4f; + float nozzle_diameter = 0.25f; + float bridge_flow = 0.f; + float layer_height = 0.5f; WHEN("layer height is set to 0.2") { layer_height = 0.15f; THEN("Max width is set.") { - auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, 0.0f); - REQUIRE(flow.width == Approx(1.4*nozzle_diameter)); + auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, bridge_flow); + REQUIRE(flow.width == Approx(1.125 * nozzle_diameter)); } } WHEN("Layer height is set to 0.2") { layer_height = 0.3f; THEN("Min width is set.") { - auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, 0.0f); - REQUIRE(flow.width == Approx(1.05*nozzle_diameter)); + auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, bridge_flow); + REQUIRE(flow.width == Approx(1.125 * nozzle_diameter)); } } } - #if 0 /// Check for an edge case in the maths where the spacing could be 0; original /// math is 0.99. Slic3r issue #4654 @@ -159,13 +158,13 @@ SCENARIO("Flow: Flow math for non-bridges", "[!mayfail]") { } /// Spacing, width calculation for bridge extrusions -SCENARIO("Flow: Flow math for bridges", "[!mayfail]") { +SCENARIO("Flow: Flow math for bridges", "[Flow]") { GIVEN("Nozzle Diameter of 0.4, a desired width of 1mm and layer height of 0.5") { auto width = ConfigOptionFloatOrPercent(1.0, false); - double spacing = 0.4; - double nozzle_diameter = 0.4; - double bridge_flow = 1.0; - double layer_height = 0.5; + float spacing = 0.4f; + float nozzle_diameter = 0.4f; + float bridge_flow = 1.0f; + float layer_height = 0.5f; WHEN("Flow role is frExternalPerimeter") { auto flow = Flow::new_from_config_width(frExternalPerimeter, width, nozzle_diameter, layer_height, bridge_flow); THEN("Bridge width is same as nozzle diameter") { diff --git a/tests/fff_print/test_gcodewriter.cpp b/tests/fff_print/test_gcodewriter.cpp index 4f1c550eb..9ee319c94 100644 --- a/tests/fff_print/test_gcodewriter.cpp +++ b/tests/fff_print/test_gcodewriter.cpp @@ -6,36 +6,7 @@ using namespace Slic3r; -SCENARIO("lift() and unlift() behavior with large values of Z", "[!shouldfail]") { - GIVEN("A config from a file and a single extruder.") { - GCodeWriter writer; - GCodeConfig &config = writer.config; - config.load(std::string(TEST_DATA_DIR) + "/fff_print_tests/test_gcodewriter/config_lift_unlift.ini"); - - std::vector extruder_ids {0}; - writer.set_extruders(extruder_ids); - writer.set_extruder(0); - - WHEN("Z is set to 9007199254740992") { - double trouble_Z = 9007199254740992; - writer.travel_to_z(trouble_Z); - AND_WHEN("GcodeWriter::Lift() is called") { - REQUIRE(writer.lift().size() > 0); - AND_WHEN("Z is moved post-lift to the same delta as the config Z lift") { - REQUIRE(writer.travel_to_z(trouble_Z + config.retract_lift.values[0]).size() == 0); - AND_WHEN("GCodeWriter::Unlift() is called") { - REQUIRE(writer.unlift().size() == 0); // we're the same height so no additional move happens. - THEN("GCodeWriter::Lift() emits gcode.") { - REQUIRE(writer.lift().size() > 0); - } - } - } - } - } - } -} - -SCENARIO("lift() is not ignored after unlift() at normal values of Z") { +SCENARIO("lift() is not ignored after unlift() at normal values of Z", "[GCodeWriter]") { GIVEN("A config from a file and a single extruder.") { GCodeWriter writer; GCodeConfig &config = writer.config; @@ -93,10 +64,11 @@ SCENARIO("lift() is not ignored after unlift() at normal values of Z") { } } } + // The test above will fail for trouble_Z == 9007199254740992, where trouble_Z + 1.5 will be rounded to trouble_Z + 2.0 due to double mantisa overflow. } } -SCENARIO("set_speed emits values with fixed-point output.") { +SCENARIO("set_speed emits values with fixed-point output.", "[GCodeWriter]") { GIVEN("GCodeWriter instance") { GCodeWriter writer; From f6057c1b4f06f02882b4c28b2054d64380c1874a Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 18 Oct 2019 16:50:03 +0200 Subject: [PATCH 4/4] test_printgcode.cpp - trying to replace std::regex with boost::regex as the std::regex is likely old or incorrect on our old debian/gcc build server. --- tests/fff_print/test_printgcode.cpp | 32 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/fff_print/test_printgcode.cpp b/tests/fff_print/test_printgcode.cpp index 5f47cfb77..10d3af9a3 100644 --- a/tests/fff_print/test_printgcode.cpp +++ b/tests/fff_print/test_printgcode.cpp @@ -6,14 +6,14 @@ #include "test_data.hpp" #include -#include +#include using namespace Slic3r; using namespace Slic3r::Test; -std::regex perimeters_regex("G1 X[-0-9.]* Y[-0-9.]* E[-0-9.]* ; perimeter"); -std::regex infill_regex("G1 X[-0-9.]* Y[-0-9.]* E[-0-9.]* ; infill"); -std::regex skirt_regex("G1 X[-0-9.]* Y[-0-9.]* E[-0-9.]* ; skirt"); +boost::regex perimeters_regex("G1 X[-0-9.]* Y[-0-9.]* E[-0-9.]* ; perimeter"); +boost::regex infill_regex("G1 X[-0-9.]* Y[-0-9.]* E[-0-9.]* ; infill"); +boost::regex skirt_regex("G1 X[-0-9.]* Y[-0-9.]* E[-0-9.]* ; skirt"); SCENARIO( "PrintGCode basic functionality", "[PrintGCode]") { GIVEN("A default configuration and a print test object") { @@ -61,16 +61,16 @@ SCENARIO( "PrintGCode basic functionality", "[PrintGCode]") { REQUIRE(gcode.find("; fill_density") != std::string::npos); } THEN("Infill is emitted.") { - std::smatch has_match; - REQUIRE(std::regex_search(gcode, has_match, infill_regex)); + boost::smatch has_match; + REQUIRE(boost::regex_search(gcode, has_match, infill_regex)); } THEN("Perimeters are emitted.") { - std::smatch has_match; - REQUIRE(std::regex_search(gcode, has_match, perimeters_regex)); + boost::smatch has_match; + REQUIRE(boost::regex_search(gcode, has_match, perimeters_regex)); } THEN("Skirt is emitted.") { - std::smatch has_match; - REQUIRE(std::regex_search(gcode, has_match, skirt_regex)); + boost::smatch has_match; + REQUIRE(boost::regex_search(gcode, has_match, skirt_regex)); } THEN("final Z height is 20mm") { double final_z = 0.0; @@ -100,16 +100,16 @@ SCENARIO( "PrintGCode basic functionality", "[PrintGCode]") { REQUIRE(gcode.size() > 0); } THEN("Infill is emitted.") { - std::smatch has_match; - REQUIRE(std::regex_search(gcode, has_match, infill_regex)); + boost::smatch has_match; + REQUIRE(boost::regex_search(gcode, has_match, infill_regex)); } THEN("Perimeters are emitted.") { - std::smatch has_match; - REQUIRE(std::regex_search(gcode, has_match, perimeters_regex)); + boost::smatch has_match; + REQUIRE(boost::regex_search(gcode, has_match, perimeters_regex)); } THEN("Skirt is emitted.") { - std::smatch has_match; - REQUIRE(std::regex_search(gcode, has_match, skirt_regex)); + boost::smatch has_match; + REQUIRE(boost::regex_search(gcode, has_match, skirt_regex)); } THEN("Between-object-gcode is emitted.") { REQUIRE(gcode.find("; between-object-gcode") != std::string::npos);