2019-10-29 16:27:53 +01:00
|
|
|
#include <iostream>
|
2019-10-31 14:36:33 +01:00
|
|
|
#include <fstream>
|
|
|
|
|
#include <catch2/catch.hpp>
|
2019-10-29 16:27:53 +01:00
|
|
|
|
2019-11-08 09:21:30 +01:00
|
|
|
#include "libslic3r/SLA/Hollowing.hpp"
|
2020-01-23 10:57:51 +01:00
|
|
|
|
2020-12-17 16:38:04 +01:00
|
|
|
TEST_CASE("Hollow two overlapping spheres") {
|
|
|
|
|
using namespace Slic3r;
|
|
|
|
|
|
|
|
|
|
TriangleMesh sphere1 = make_sphere(10., 2 * PI / 20.), sphere2 = sphere1;
|
|
|
|
|
|
|
|
|
|
sphere1.translate(-5.f, 0.f, 0.f);
|
|
|
|
|
sphere2.translate( 5.f, 0.f, 0.f);
|
|
|
|
|
|
|
|
|
|
sphere1.merge(sphere2);
|
|
|
|
|
sphere1.require_shared_vertices();
|
|
|
|
|
|
|
|
|
|
sla::hollow_mesh(sphere1, sla::HollowingConfig{}, sla::HollowingFlags::hfRemoveInsideTriangles);
|
|
|
|
|
|
|
|
|
|
sphere1.WriteOBJFile("twospheres.obj");
|
2019-10-29 16:27:53 +01:00
|
|
|
}
|
2020-01-23 10:57:51 +01:00
|
|
|
|
2021-05-26 16:41:34 +02:00
|
|
|
TEST_CASE("Split its") {
|
|
|
|
|
using namespace Slic3r;
|
|
|
|
|
|
|
|
|
|
TriangleMesh sphere1 = make_sphere(10., 2 * PI / 20.), sphere2 = sphere1;
|
|
|
|
|
|
|
|
|
|
sphere1.translate(-5.f, 0.f, 0.f);
|
|
|
|
|
sphere2.translate( 5.f, 0.f, 0.f);
|
|
|
|
|
|
|
|
|
|
sphere1.merge(sphere2);
|
|
|
|
|
sphere1.require_shared_vertices();
|
|
|
|
|
|
|
|
|
|
std::vector<indexed_triangle_set> parts;
|
|
|
|
|
its_split(sphere1.its, std::back_inserter(parts));
|
|
|
|
|
|
|
|
|
|
size_t part_idx = 0;
|
|
|
|
|
for (auto &part_its : parts) {
|
|
|
|
|
its_write_obj(part_its, (std::string("part_its") + std::to_string(part_idx++) + ".obj").c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|