mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-17 19:57:55 -06:00
Add new (winner) neighbor index based on measurements
This commit is contained in:
parent
b14b000c73
commit
c4507842a0
11 changed files with 327 additions and 125 deletions
|
@ -17,35 +17,86 @@ TEST_CASE("Split empty mesh", "[its_split][its]") {
|
|||
TEST_CASE("Split simple mesh consisting of one part", "[its_split][its]") {
|
||||
using namespace Slic3r;
|
||||
|
||||
TriangleMesh cube = make_cube(10., 10., 10.);
|
||||
auto cube = its_make_cube(10., 10., 10.);
|
||||
|
||||
std::vector<indexed_triangle_set> res = its_split(cube.its);
|
||||
std::vector<indexed_triangle_set> res = its_split(cube);
|
||||
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res.front().indices.size() == cube.its.indices.size());
|
||||
REQUIRE(res.front().vertices.size() == cube.its.vertices.size());
|
||||
REQUIRE(res.front().indices.size() == cube.indices.size());
|
||||
REQUIRE(res.front().vertices.size() == cube.vertices.size());
|
||||
}
|
||||
|
||||
TEST_CASE("Split two merged spheres", "[its_split][its]") {
|
||||
using namespace Slic3r;
|
||||
|
||||
TriangleMesh sphere1 = make_sphere(10., 2 * PI / 200.), 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);
|
||||
|
||||
REQUIRE(parts.size() == 2);
|
||||
|
||||
void debug_write_obj(const std::vector<indexed_triangle_set> &res, const std::string &name)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
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());
|
||||
for (auto &part_its : res) {
|
||||
its_write_obj(part_its, (name + std::to_string(part_idx++) + ".obj").c_str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE("Split two non-watertight mesh", "[its_split][its]") {
|
||||
using namespace Slic3r;
|
||||
|
||||
auto cube1 = its_make_cube(10., 10., 10.);
|
||||
cube1.indices.pop_back();
|
||||
auto cube2 = cube1;
|
||||
|
||||
its_transform(cube1, identity3f().translate(Vec3f{-5.f, 0.f, 0.f}));
|
||||
its_transform(cube2, identity3f().translate(Vec3f{5.f, 0.f, 0.f}));
|
||||
|
||||
its_merge(cube1, cube2);
|
||||
|
||||
std::vector<indexed_triangle_set> res = its_split(cube1);
|
||||
|
||||
REQUIRE(res.size() == 2);
|
||||
REQUIRE(res[0].indices.size() == res[1].indices.size());
|
||||
REQUIRE(res[0].indices.size() == cube2.indices.size());
|
||||
REQUIRE(res[0].vertices.size() == res[1].vertices.size());
|
||||
REQUIRE(res[0].vertices.size() == cube2.vertices.size());
|
||||
|
||||
debug_write_obj(res, "parts_non_watertight");
|
||||
}
|
||||
|
||||
TEST_CASE("Split non-manifold mesh", "[its_split][its]") {
|
||||
using namespace Slic3r;
|
||||
|
||||
auto cube = its_make_cube(10., 10., 10.), cube_low = cube;
|
||||
|
||||
its_transform(cube_low, identity3f().translate(Vec3f{10.f, 10.f, 10.f}));
|
||||
its_merge(cube, cube_low);
|
||||
its_merge_vertices(cube);
|
||||
|
||||
std::vector<indexed_triangle_set> res = its_split(cube);
|
||||
|
||||
REQUIRE(res.size() == 2);
|
||||
REQUIRE(res[0].indices.size() == res[1].indices.size());
|
||||
REQUIRE(res[0].indices.size() == cube_low.indices.size());
|
||||
REQUIRE(res[0].vertices.size() == res[1].vertices.size());
|
||||
REQUIRE(res[0].vertices.size() == cube_low.vertices.size());
|
||||
|
||||
debug_write_obj(res, "cubes_non_manifold");
|
||||
}
|
||||
|
||||
TEST_CASE("Split two watertight meshes", "[its_split][its]") {
|
||||
using namespace Slic3r;
|
||||
|
||||
auto sphere1 = its_make_sphere(10., 2 * PI / 200.), sphere2 = sphere1;
|
||||
|
||||
its_transform(sphere1, identity3f().translate(Vec3f{-5.f, 0.f, 0.f}));
|
||||
its_transform(sphere2, identity3f().translate(Vec3f{5.f, 0.f, 0.f}));
|
||||
|
||||
its_merge(sphere1, sphere2);
|
||||
|
||||
std::vector<indexed_triangle_set> res = its_split(sphere1);
|
||||
|
||||
REQUIRE(res.size() == 2);
|
||||
REQUIRE(res[0].indices.size() == res[1].indices.size());
|
||||
REQUIRE(res[0].indices.size() == sphere2.indices.size());
|
||||
REQUIRE(res[0].vertices.size() == res[1].vertices.size());
|
||||
REQUIRE(res[0].vertices.size() == sphere2.vertices.size());
|
||||
|
||||
debug_write_obj(res, "parts_watertight");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue