Files
OrcaSlicer/tests/libslic3r/test_hollowing.cpp
Kris Austin 9921437c27 Fail tests whose sections assert nothing (#17420)
tests/CATCH2.md says to run the suites with `--order rand --warn
NoAssertions`. On main that fails in fff_print (8 test cases), libslic3r
(15), sla_print (1) and slic3rutils (4), even when each case runs alone.
ctest never passed the flag, so nothing stopped new ones. Most of these
tests have SECTIONs that only set up state, with the assertions after
them, or generated cases that return early for combinations that don't
apply. Catch2 counts assertions per section, so each of those reads as
an empty test.

Where only a value or a short setup changes, use GENERATE or a table and
generate only the combinations that apply. Elsewhere, end each section
with a call to a local check. ctest now passes `--warn NoAssertions`, so
CI fails a case or section that asserts nothing, and tests/AGENTS.md
says so. ctest also passes the CATCH_EXTRA_ARGS cache variable, which
nothing read before, split like a command line, so setting it now takes
effect.

Three tests only wrote a debug mesh or diagram and asserted nothing.
They now check that the Voronoi diagram of the six points is complete,
that hollowing with hfRemoveInsideTriangles removes at least half of the
roughly 400 mm² of the two spheres that lies deeper than the wall, and
that the half cone is closed. The legacy 3MF scenario checked for a
volume map on every plate of a file that has none, so it now also saves
and loads a project with a plate, and its name says so.
2026-11-14 10:47:42 -06:00

41 lines
1.4 KiB
C++

#include <iostream>
#include <fstream>
#include <catch2/catch_all.hpp>
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/libslic3r.h"
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/SLA/Hollowing.hpp"
#include "test_utils.hpp"
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);
const auto area = [](const indexed_triangle_set &its) {
double sum = 0.;
for (const auto &f : its.indices)
sum += 0.5 * double((its.vertices[f[1]] - its.vertices[f[0]]).cross(its.vertices[f[2]] - its.vertices[f[0]]).norm());
return sum;
};
const sla::InteriorPtr interior = sla::generate_interior(sphere1);
REQUIRE(interior);
const double merged_area = area(sphere1.its);
const double interior_area = area(sla::get_mesh(*interior));
REQUIRE(interior_area > 0.);
sla::hollow_mesh(sphere1, *interior, sla::HollowingFlags::hfRemoveInsideTriangles);
// The cavity is added, less the roughly 400 square mm of the two spheres that lie inside each other deeper than
// the wall, so at least 200 must go.
CHECK(area(sphere1.its) < merged_area + interior_area - 200.);
write_debug_obj("hollowing/twospheres.obj", sphere1);
}