2022-04-26 08:57:49 +00:00
|
|
|
#include <catch2/catch.hpp>
|
|
|
|
#include <test_utils.hpp>
|
|
|
|
|
|
|
|
#include "libslic3r/SLAPrint.hpp"
|
|
|
|
#include "libslic3r/TriangleMesh.hpp"
|
2023-04-05 14:58:54 +00:00
|
|
|
#include "libslic3r/Format/SLAArchiveFormatRegistry.hpp"
|
2022-04-26 08:57:49 +00:00
|
|
|
#include "libslic3r/Format/SLAArchiveWriter.hpp"
|
|
|
|
#include "libslic3r/Format/SLAArchiveReader.hpp"
|
|
|
|
|
|
|
|
#include <boost/filesystem.hpp>
|
|
|
|
|
|
|
|
using namespace Slic3r;
|
|
|
|
|
|
|
|
TEST_CASE("Archive export test", "[sla_archives]") {
|
2023-04-05 14:58:54 +00:00
|
|
|
auto registry = registered_sla_archives();
|
|
|
|
|
2022-04-26 12:43:07 +00:00
|
|
|
for (const char * pname : {"20mm_cube", "extruder_idler"})
|
2023-04-05 14:58:54 +00:00
|
|
|
for (const ArchiveEntry &entry : registry) {
|
|
|
|
INFO(std::string("Testing archive type: ") + entry.id + " -- writing...");
|
2022-04-26 08:57:49 +00:00
|
|
|
SLAPrint print;
|
|
|
|
SLAFullPrintConfig fullcfg;
|
|
|
|
|
2022-04-26 12:43:07 +00:00
|
|
|
auto m = Model::read_from_file(TEST_DATA_DIR PATH_SEPARATOR + std::string(pname) + ".obj", nullptr);
|
2022-04-26 08:57:49 +00:00
|
|
|
|
|
|
|
fullcfg.printer_technology.setInt(ptSLA); // FIXME this should be ensured
|
2023-04-05 14:58:54 +00:00
|
|
|
fullcfg.set("sla_archive_format", entry.id);
|
2022-04-26 08:57:49 +00:00
|
|
|
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;
|
2023-04-05 14:58:54 +00:00
|
|
|
auto outputfname = std::string("output_") + pname + "." + entry.ext;
|
2022-04-26 08:57:49 +00:00
|
|
|
|
2022-04-26 12:43:07 +00:00
|
|
|
print.export_print(outputfname, thumbnails, pname);
|
2022-04-26 08:57:49 +00:00
|
|
|
|
|
|
|
// Not much can be checked about the archives...
|
|
|
|
REQUIRE(boost::filesystem::exists(outputfname));
|
|
|
|
|
|
|
|
double vol_written = m.mesh().volume();
|
|
|
|
|
2023-04-05 14:58:54 +00:00
|
|
|
if (entry.rdfactoryfn) {
|
|
|
|
INFO(std::string("Testing archive type: ") + entry.id + " -- reading back...");
|
2022-04-26 08:57:49 +00:00
|
|
|
indexed_triangle_set its;
|
|
|
|
DynamicPrintConfig cfg;
|
|
|
|
|
|
|
|
try {
|
2022-04-26 12:43:07 +00:00
|
|
|
// Leave format_id deliberetaly empty, guessing should always
|
|
|
|
// work here.
|
|
|
|
import_sla_archive(outputfname, "", its, cfg);
|
2022-04-26 08:57:49 +00:00
|
|
|
} catch (...) {
|
|
|
|
REQUIRE(false);
|
|
|
|
}
|
|
|
|
|
2022-04-26 12:43:07 +00:00
|
|
|
// its_write_obj(its, (outputfname + ".obj").c_str());
|
|
|
|
|
2022-04-26 08:57:49 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|