2019-10-29 15:27:53 +00:00
|
|
|
#include <iostream>
|
2019-10-31 13:36:33 +00:00
|
|
|
#include <fstream>
|
|
|
|
#include <catch2/catch.hpp>
|
2019-10-29 15:27:53 +00:00
|
|
|
|
2019-11-01 14:31:26 +00:00
|
|
|
#include "libslic3r/OpenVDBUtils.hpp"
|
2019-10-29 15:27:53 +00:00
|
|
|
#include "libslic3r/Format/OBJ.hpp"
|
|
|
|
|
|
|
|
#if defined(WIN32) || defined(_WIN32)
|
|
|
|
#define PATH_SEPARATOR R"(\)"
|
|
|
|
#else
|
|
|
|
#define PATH_SEPARATOR R"(/)"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static Slic3r::TriangleMesh load_model(const std::string &obj_filename)
|
|
|
|
{
|
|
|
|
Slic3r::TriangleMesh mesh;
|
|
|
|
auto fpath = TEST_DATA_DIR PATH_SEPARATOR + obj_filename;
|
|
|
|
Slic3r::load_obj(fpath.c_str(), &mesh);
|
|
|
|
return mesh;
|
|
|
|
}
|
|
|
|
|
2019-10-30 11:38:23 +00:00
|
|
|
TEST_CASE("Load object", "[Hollowing]") {
|
2019-10-31 13:36:33 +00:00
|
|
|
Slic3r::TriangleMesh mesh = load_model("20mm_cube.obj");
|
|
|
|
|
|
|
|
Slic3r::sla::Contour3D imesh = Slic3r::sla::convert_mesh(mesh);
|
|
|
|
auto ptr = Slic3r::meshToVolume(imesh, {});
|
2019-10-29 15:27:53 +00:00
|
|
|
|
2019-10-30 11:38:23 +00:00
|
|
|
REQUIRE(ptr);
|
|
|
|
|
2019-10-31 13:36:33 +00:00
|
|
|
Slic3r::sla::Contour3D omesh = Slic3r::volumeToMesh(*ptr, -1., 0.0, true);
|
|
|
|
|
|
|
|
REQUIRE(!omesh.empty());
|
2019-10-30 11:38:23 +00:00
|
|
|
|
2019-10-31 13:36:33 +00:00
|
|
|
std::fstream outfile{"out.obj", std::ios::out};
|
|
|
|
omesh.to_obj(outfile);
|
2019-10-30 11:38:23 +00:00
|
|
|
|
2019-10-31 13:36:33 +00:00
|
|
|
imesh.merge(omesh);
|
|
|
|
std::fstream merged_outfile("merged_out.obj", std::ios::out);
|
|
|
|
imesh.to_obj(merged_outfile);
|
2019-10-29 15:27:53 +00:00
|
|
|
}
|