TriangleMeshSlicer: Got rid of admesh!

This commit is contained in:
Vojtech Bubnik 2021-05-18 15:05:23 +02:00
parent 1256aebd88
commit 70b4915f9c
18 changed files with 443 additions and 452 deletions

View file

@ -356,27 +356,25 @@ SCENARIO( "TriangleMeshSlicer: Cut behavior.") {
TriangleMesh cube(vertices, facets);
cube.repair();
WHEN( "Object is cut at the bottom") {
TriangleMesh upper {};
TriangleMesh lower {};
TriangleMeshSlicer slicer(&cube);
slicer.cut(0, &upper, &lower);
indexed_triangle_set upper {};
indexed_triangle_set lower {};
cut_mesh(cube.its, 0, &upper, &lower);
THEN("Upper mesh has all facets except those belonging to the slicing plane.") {
REQUIRE(upper.facets_count() == 12);
REQUIRE(upper.indices.size() == 12);
}
THEN("Lower mesh has no facets.") {
REQUIRE(lower.facets_count() == 0);
REQUIRE(lower.indices.size() == 0);
}
}
WHEN( "Object is cut at the center") {
TriangleMesh upper {};
TriangleMesh lower {};
TriangleMeshSlicer slicer(&cube);
slicer.cut(10, &upper, &lower);
indexed_triangle_set upper {};
indexed_triangle_set lower {};
cut_mesh(cube.its, 10, &upper, &lower);
THEN("Upper mesh has 2 external horizontal facets, 3 facets on each side, and 6 facets on the triangulated side (2 + 12 + 6).") {
REQUIRE(upper.facets_count() == 2+12+6);
REQUIRE(upper.indices.size() == 2+12+6);
}
THEN("Lower mesh has 2 external horizontal facets, 3 facets on each side, and 6 facets on the triangulated side (2 + 12 + 6).") {
REQUIRE(lower.facets_count() == 2+12+6);
REQUIRE(lower.indices.size() == 2+12+6);
}
}
}

View file

@ -320,8 +320,8 @@ static void recreate_object_from_rasters(const std::string &objname, float lh) {
mesh.translate(tr.x(), tr.y(), tr.z());
bb = mesh.bounding_box();
std::vector<ExPolygons> layers;
slice_mesh(mesh, grid(float(bb.min.z()) + lh, float(bb.max.z()), lh), layers);
assert(mesh.has_shared_vertices());
std::vector<ExPolygons> layers = slice_mesh_ex(mesh.its, grid(float(bb.min.z()) + lh, float(bb.max.z()), lh));
sla::RasterBase::Resolution res{2560, 1440};
double disp_w = 120.96;

View file

@ -57,8 +57,8 @@ TEST_CASE("Support point generator should be deterministic if seeded",
auto layer_h = 0.05f;
auto slicegrid = grid(float(gnd), float(zmax), layer_h);
std::vector<ExPolygons> slices;
slice_mesh(mesh, slicegrid, CLOSING_RADIUS, slices);
assert(mesh.has_shared_vertices());
std::vector<ExPolygons> slices = slice_mesh_ex(mesh.its, slicegrid, CLOSING_RADIUS);
point_gen.seed(0);
point_gen.execute(slices, slicegrid);

View file

@ -102,7 +102,8 @@ void test_supports(const std::string &obj_filename,
auto layer_h = 0.05f;
out.slicegrid = grid(float(gnd), float(zmax), layer_h);
slice_mesh(mesh, out.slicegrid, CLOSING_RADIUS, out.model_slices);
assert(mesh.has_shared_vertices());
out.model_slices = slice_mesh_ex(mesh.its, out.slicegrid, CLOSING_RADIUS);
sla::cut_drainholes(out.model_slices, out.slicegrid, CLOSING_RADIUS, drainholes, []{});
// Create the special index-triangle mesh with spatial indexing which
@ -466,10 +467,10 @@ sla::SupportPoints calc_support_pts(
const sla::SupportPointGenerator::Config &cfg)
{
// Prepare the slice grid and the slices
std::vector<ExPolygons> slices;
auto bb = cast<float>(mesh.bounding_box());
std::vector<float> heights = grid(bb.min.z(), bb.max.z(), 0.1f);
slice_mesh(mesh, heights, CLOSING_RADIUS, slices);
assert(mesh.has_shared_vertices());
std::vector<ExPolygons> slices = slice_mesh_ex(mesh.its, heights, CLOSING_RADIUS);
// Prepare the support point calculator
sla::IndexedMesh emesh{mesh};