mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 09:47:58 -06:00
Test sla support point generation determinism with seed parameter
This commit is contained in:
parent
8af6890cab
commit
ce49f0a294
2 changed files with 49 additions and 1 deletions
|
@ -31,7 +31,8 @@ public:
|
||||||
|
|
||||||
SupportPointGenerator(const EigenMesh3D& emesh, const Config& config, std::function<void(void)> throw_on_cancel, std::function<void(int)> statusfn);
|
SupportPointGenerator(const EigenMesh3D& emesh, const Config& config, std::function<void(void)> throw_on_cancel, std::function<void(int)> statusfn);
|
||||||
|
|
||||||
const std::vector<SupportPoint>& output() { return m_output; }
|
const std::vector<SupportPoint>& output() const { return m_output; }
|
||||||
|
std::vector<SupportPoint>& output() { return m_output; }
|
||||||
|
|
||||||
struct MyLayer;
|
struct MyLayer;
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,53 @@ TEST_CASE("Pillar pairhash should be unique", "[SLASupportGeneration]") {
|
||||||
test_pairhash<unsigned, unsigned long>();
|
test_pairhash<unsigned, unsigned long>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Support point generator should be deterministic if seeded",
|
||||||
|
"[SLASupportGeneration], [SLAPointGen]") {
|
||||||
|
TriangleMesh mesh = load_model("A_upsidedown.obj");
|
||||||
|
|
||||||
|
sla::EigenMesh3D emesh{mesh};
|
||||||
|
|
||||||
|
sla::SupportConfig supportcfg;
|
||||||
|
sla::SupportPointGenerator::Config autogencfg;
|
||||||
|
autogencfg.head_diameter = float(2 * supportcfg.head_front_radius_mm);
|
||||||
|
sla::SupportPointGenerator point_gen{emesh, autogencfg, [] {}, [](int) {}};
|
||||||
|
|
||||||
|
TriangleMeshSlicer slicer{&mesh};
|
||||||
|
|
||||||
|
auto bb = mesh.bounding_box();
|
||||||
|
double zmin = bb.min.z();
|
||||||
|
double zmax = bb.max.z();
|
||||||
|
double gnd = zmin - supportcfg.object_elevation_mm;
|
||||||
|
auto layer_h = 0.05f;
|
||||||
|
|
||||||
|
auto slicegrid = grid(float(gnd), float(zmax), layer_h);
|
||||||
|
std::vector<ExPolygons> slices;
|
||||||
|
slicer.slice(slicegrid, CLOSING_RADIUS, &slices, []{});
|
||||||
|
|
||||||
|
point_gen.execute(slices, slicegrid, 0);
|
||||||
|
|
||||||
|
auto get_chksum = [](const std::vector<sla::SupportPoint> &pts){
|
||||||
|
long long chksum = 0;
|
||||||
|
for (auto &pt : pts) {
|
||||||
|
auto p = scaled(pt.pos);
|
||||||
|
chksum += p.x() + p.y() + p.z();
|
||||||
|
}
|
||||||
|
|
||||||
|
return chksum;
|
||||||
|
};
|
||||||
|
|
||||||
|
long long checksum = get_chksum(point_gen.output());
|
||||||
|
size_t ptnum = point_gen.output().size();
|
||||||
|
REQUIRE(point_gen.output().size() > 0);
|
||||||
|
|
||||||
|
for (int i = 0; i < 20; ++i) {
|
||||||
|
point_gen.output().clear();
|
||||||
|
point_gen.execute(slices, slicegrid, 0);
|
||||||
|
REQUIRE(point_gen.output().size() == ptnum);
|
||||||
|
REQUIRE(checksum == get_chksum(point_gen.output()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("Flat pad geometry is valid", "[SLASupportGeneration]") {
|
TEST_CASE("Flat pad geometry is valid", "[SLASupportGeneration]") {
|
||||||
sla::PadConfig padcfg;
|
sla::PadConfig padcfg;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue