From 6e6b137151f63a6c6bc89a7f5c5875fc73784819 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 18 Oct 2019 14:42:03 +0200 Subject: [PATCH] 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))); + } + } } }