Initial tests for import of ASCII STLs with varying line endings.
This commit is contained in:
parent
e04e2b3636
commit
070070edba
1
tests/data/test_stl/ASCII/20mmbox-CR.stl
Normal file
1
tests/data/test_stl/ASCII/20mmbox-CR.stl
Normal file
@ -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
|
86
tests/data/test_stl/ASCII/20mmbox-CRLF.stl
Normal file
86
tests/data/test_stl/ASCII/20mmbox-CRLF.stl
Normal file
@ -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
|
86
tests/data/test_stl/ASCII/20mmbox-LF.stl
Normal file
86
tests/data/test_stl/ASCII/20mmbox-LF.stl
Normal file
@ -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
|
BIN
tests/data/test_stl/Geräte/20mmbox-čřšřěá.stl
Normal file
BIN
tests/data/test_stl/Geräte/20mmbox-čřšřěá.stl
Normal file
Binary file not shown.
@ -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")
|
||||
|
@ -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") {
|
||||
|
49
tests/libslic3r/test_stl.cpp
Normal file
49
tests/libslic3r/test_stl.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user