Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authortamasmeszaros <meszaros.q@gmail.com>2022-04-26 11:57:49 +0300
committertamasmeszaros <meszaros.q@gmail.com>2022-04-26 11:57:49 +0300
commit784105f5adfcf5ee46c748c7b36af73fd3b89b35 (patch)
tree058e95db58fa94933b9d41715c6ac194184aa25c /tests
parent0025a656119fa40991026ce13bc4d062fa3bdb83 (diff)
Extend sla archive tests with read-back
Diffstat (limited to 'tests')
-rw-r--r--tests/sla_print/CMakeLists.txt2
-rw-r--r--tests/sla_print/sla_archive_export_tests.cpp40
-rw-r--r--tests/sla_print/sla_archive_readwrite_tests.cpp68
3 files changed, 69 insertions, 41 deletions
diff --git a/tests/sla_print/CMakeLists.txt b/tests/sla_print/CMakeLists.txt
index 88c1cd186..a26d5f480 100644
--- a/tests/sla_print/CMakeLists.txt
+++ b/tests/sla_print/CMakeLists.txt
@@ -4,7 +4,7 @@ add_executable(${_TEST_NAME}_tests ${_TEST_NAME}_tests_main.cpp
sla_test_utils.hpp sla_test_utils.cpp
sla_supptgen_tests.cpp
sla_raycast_tests.cpp
- sla_archive_export_tests.cpp)
+ sla_archive_readwrite_tests.cpp)
target_link_libraries(${_TEST_NAME}_tests test_common libslic3r)
set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests")
diff --git a/tests/sla_print/sla_archive_export_tests.cpp b/tests/sla_print/sla_archive_export_tests.cpp
deleted file mode 100644
index 2c0d68c3c..000000000
--- a/tests/sla_print/sla_archive_export_tests.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-#include <catch2/catch.hpp>
-#include <test_utils.hpp>
-
-#include "libslic3r/SLAPrint.hpp"
-#include "libslic3r/Format/SLAArchiveWriter.hpp"
-
-#include <boost/filesystem.hpp>
-
-using namespace Slic3r;
-
-TEST_CASE("Archive export test", "[sla_archives]") {
- constexpr const char *PNAME = "20mm_cube";
-
- for (auto &archname : SLAArchiveWriter::registered_archives()) {
- INFO(std::string("Testing archive type: ") + archname);
- SLAPrint print;
- SLAFullPrintConfig fullcfg;
-
- auto m = Model::read_from_file(TEST_DATA_DIR PATH_SEPARATOR + std::string(PNAME) + ".obj", nullptr);
-
- fullcfg.set("sla_archive_format", archname);
- fullcfg.set("supports_enable", false);
- fullcfg.set("pad_enable", false);
-
- DynamicPrintConfig cfg;
- cfg.apply(fullcfg);
-
- print.set_status_callback([](const PrintBase::SlicingStatus&) {});
- print.apply(m, cfg);
- print.process();
-
- ThumbnailsList thumbnails;
- auto outputfname = std::string("output.") + SLAArchiveWriter::get_extension(archname);
-
- print.export_print(outputfname, thumbnails, PNAME);
-
- // Not much can be checked about the archives...
- REQUIRE(boost::filesystem::exists(outputfname));
- }
-}
diff --git a/tests/sla_print/sla_archive_readwrite_tests.cpp b/tests/sla_print/sla_archive_readwrite_tests.cpp
new file mode 100644
index 000000000..251d7e8f3
--- /dev/null
+++ b/tests/sla_print/sla_archive_readwrite_tests.cpp
@@ -0,0 +1,68 @@
+#include <catch2/catch.hpp>
+#include <test_utils.hpp>
+
+#include "libslic3r/SLAPrint.hpp"
+#include "libslic3r/TriangleMesh.hpp"
+#include "libslic3r/Format/SLAArchiveWriter.hpp"
+#include "libslic3r/Format/SLAArchiveReader.hpp"
+
+#include <boost/filesystem.hpp>
+
+using namespace Slic3r;
+
+TEST_CASE("Archive export test", "[sla_archives]") {
+ constexpr const char *PNAME = "extruder_idler";
+
+ for (auto &archname : SLAArchiveWriter::registered_archives()) {
+ INFO(std::string("Testing archive type: ") + archname + " -- writing...");
+ SLAPrint print;
+ SLAFullPrintConfig fullcfg;
+
+ auto m = Model::read_from_file(TEST_DATA_DIR PATH_SEPARATOR + std::string(PNAME) + ".obj", nullptr);
+
+ fullcfg.printer_technology.setInt(ptSLA); // FIXME this should be ensured
+ fullcfg.set("sla_archive_format", archname);
+ fullcfg.set("supports_enable", false);
+ fullcfg.set("pad_enable", false);
+
+ DynamicPrintConfig cfg;
+ cfg.apply(fullcfg);
+
+ print.set_status_callback([](const PrintBase::SlicingStatus&) {});
+ print.apply(m, cfg);
+ print.process();
+
+ ThumbnailsList thumbnails;
+ auto outputfname = std::string("output.") + SLAArchiveWriter::get_extension(archname);
+
+ print.export_print(outputfname, thumbnails, PNAME);
+
+ // Not much can be checked about the archives...
+ REQUIRE(boost::filesystem::exists(outputfname));
+
+ double vol_written = m.mesh().volume();
+
+ auto readable_formats = SLAArchiveReader::registered_archives();
+ if (std::any_of(readable_formats.begin(), readable_formats.end(),
+ [&archname](const std::string &a) { return a == archname; })) {
+
+ INFO(std::string("Testing archive type: ") + archname + " -- reading back...");
+
+ indexed_triangle_set its;
+ DynamicPrintConfig cfg;
+
+ try {
+ import_sla_archive(outputfname, its, cfg);
+ } catch (...) {
+ REQUIRE(false);
+ }
+
+ REQUIRE(!cfg.empty());
+ REQUIRE(!its.empty());
+
+ double vol_read = its_volume(its);
+ double rel_err = std::abs(vol_written - vol_read) / vol_written;
+ REQUIRE(rel_err < 0.1);
+ }
+ }
+}