Fixed conflicts after merge with master

This commit is contained in:
enricoturri1966 2020-08-04 09:58:19 +02:00
commit 25c3552555
68 changed files with 4042 additions and 1798 deletions

View file

@ -1,7 +1,7 @@
get_filename_component(_TEST_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
add_executable(${_TEST_NAME}_tests ${_TEST_NAME}_tests_main.cpp
sla_print_tests.cpp
sla_test_utils.hpp sla_test_utils.cpp
sla_test_utils.hpp sla_test_utils.cpp sla_treebuilder_tests.cpp
sla_raycast_tests.cpp)
target_link_libraries(${_TEST_NAME}_tests test_common libslic3r)
set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests")

View file

@ -4,6 +4,8 @@
#include "sla_test_utils.hpp"
#include <libslic3r/SLA/SupportTreeMesher.hpp>
namespace {
const char *const BELOW_PAD_TEST_OBJECTS[] = {
@ -37,9 +39,9 @@ TEST_CASE("Support point generator should be deterministic if seeded",
"[SLASupportGeneration], [SLAPointGen]") {
TriangleMesh mesh = load_model("A_upsidedown.obj");
sla::EigenMesh3D emesh{mesh};
sla::IndexedMesh emesh{mesh};
sla::SupportConfig supportcfg;
sla::SupportTreeConfig supportcfg;
sla::SupportPointGenerator::Config autogencfg;
autogencfg.head_diameter = float(2 * supportcfg.head_front_radius_mm);
sla::SupportPointGenerator point_gen{emesh, autogencfg, [] {}, [](int) {}};
@ -124,14 +126,14 @@ TEST_CASE("WingedPadAroundObjectIsValid", "[SLASupportGeneration]") {
}
TEST_CASE("ElevatedSupportGeometryIsValid", "[SLASupportGeneration]") {
sla::SupportConfig supportcfg;
sla::SupportTreeConfig supportcfg;
supportcfg.object_elevation_mm = 5.;
for (auto fname : SUPPORT_TEST_MODELS) test_supports(fname);
}
TEST_CASE("FloorSupportGeometryIsValid", "[SLASupportGeneration]") {
sla::SupportConfig supportcfg;
sla::SupportTreeConfig supportcfg;
supportcfg.object_elevation_mm = 0;
for (auto &fname: SUPPORT_TEST_MODELS) test_supports(fname, supportcfg);
@ -139,7 +141,7 @@ TEST_CASE("FloorSupportGeometryIsValid", "[SLASupportGeneration]") {
TEST_CASE("ElevatedSupportsDoNotPierceModel", "[SLASupportGeneration]") {
sla::SupportConfig supportcfg;
sla::SupportTreeConfig supportcfg;
for (auto fname : SUPPORT_TEST_MODELS)
test_support_model_collision(fname, supportcfg);
@ -147,7 +149,7 @@ TEST_CASE("ElevatedSupportsDoNotPierceModel", "[SLASupportGeneration]") {
TEST_CASE("FloorSupportsDoNotPierceModel", "[SLASupportGeneration]") {
sla::SupportConfig supportcfg;
sla::SupportTreeConfig supportcfg;
supportcfg.object_elevation_mm = 0;
for (auto fname : SUPPORT_TEST_MODELS)
@ -228,3 +230,12 @@ TEST_CASE("Triangle mesh conversions should be correct", "[SLAConversions]")
cntr.from_obj(infile);
}
}
TEST_CASE("halfcone test", "[halfcone]") {
sla::DiffBridge br{Vec3d{1., 1., 1.}, Vec3d{10., 10., 10.}, 0.25, 0.5};
TriangleMesh m = sla::to_triangle_mesh(sla::get_mesh(br, 45));
m.require_shared_vertices();
m.WriteOBJFile("Halfcone.obj");
}

View file

@ -1,7 +1,7 @@
#include <catch2/catch.hpp>
#include <test_utils.hpp>
#include <libslic3r/SLA/EigenMesh3D.hpp>
#include <libslic3r/SLA/IndexedMesh.hpp>
#include <libslic3r/SLA/Hollowing.hpp>
#include "sla_test_utils.hpp"
@ -65,7 +65,7 @@ TEST_CASE("Raycaster with loaded drillholes", "[sla_raycast]")
cube.merge(*cube_inside);
cube.require_shared_vertices();
sla::EigenMesh3D emesh{cube};
sla::IndexedMesh emesh{cube};
emesh.load_holes(holes);
Vec3d s = center.cast<double>();

View file

@ -2,13 +2,13 @@
#include "libslic3r/SLA/AGGRaster.hpp"
void test_support_model_collision(const std::string &obj_filename,
const sla::SupportConfig &input_supportcfg,
const sla::SupportTreeConfig &input_supportcfg,
const sla::HollowingConfig &hollowingcfg,
const sla::DrainHoles &drainholes)
{
SupportByproducts byproducts;
sla::SupportConfig supportcfg = input_supportcfg;
sla::SupportTreeConfig supportcfg = input_supportcfg;
// Set head penetration to a small negative value which should ensure that
// the supports will not touch the model body.
@ -69,11 +69,12 @@ void export_failed_case(const std::vector<ExPolygons> &support_slices, const Sup
m.merge(byproducts.input_mesh);
m.repair();
m.require_shared_vertices();
m.WriteOBJFile(byproducts.obj_fname.c_str());
m.WriteOBJFile((Catch::getResultCapture().getCurrentTestName() + "_" +
byproducts.obj_fname).c_str());
}
void test_supports(const std::string &obj_filename,
const sla::SupportConfig &supportcfg,
const sla::SupportTreeConfig &supportcfg,
const sla::HollowingConfig &hollowingcfg,
const sla::DrainHoles &drainholes,
SupportByproducts &out)
@ -104,7 +105,7 @@ void test_supports(const std::string &obj_filename,
// Create the special index-triangle mesh with spatial indexing which
// is the input of the support point and support mesh generators
sla::EigenMesh3D emesh{mesh};
sla::IndexedMesh emesh{mesh};
#ifdef SLIC3R_HOLE_RAYCASTER
if (hollowingcfg.enabled)
@ -129,8 +130,7 @@ void test_supports(const std::string &obj_filename,
// If there is no elevation, support points shall be removed from the
// bottom of the object.
if (std::abs(supportcfg.object_elevation_mm) < EPSILON) {
sla::remove_bottom_points(support_points, zmin,
supportcfg.base_height_mm);
sla::remove_bottom_points(support_points, zmin + supportcfg.base_height_mm);
} else {
// Should be support points at least on the bottom of the model
REQUIRE_FALSE(support_points.empty());
@ -141,7 +141,8 @@ void test_supports(const std::string &obj_filename,
// Generate the actual support tree
sla::SupportTreeBuilder treebuilder;
treebuilder.build(sla::SupportableMesh{emesh, support_points, supportcfg});
sla::SupportableMesh sm{emesh, support_points, supportcfg};
sla::SupportTreeBuildsteps::execute(treebuilder, sm);
check_support_tree_integrity(treebuilder, supportcfg);
@ -157,8 +158,8 @@ void test_supports(const std::string &obj_filename,
if (std::abs(supportcfg.object_elevation_mm) < EPSILON)
allowed_zmin = zmin - 2 * supportcfg.head_back_radius_mm;
REQUIRE(obb.min.z() >= allowed_zmin);
REQUIRE(obb.max.z() <= zmax);
REQUIRE(obb.min.z() >= Approx(allowed_zmin));
REQUIRE(obb.max.z() <= Approx(zmax));
// Move out the support tree into the byproducts, we can examine it further
// in various tests.
@ -168,15 +169,15 @@ void test_supports(const std::string &obj_filename,
}
void check_support_tree_integrity(const sla::SupportTreeBuilder &stree,
const sla::SupportConfig &cfg)
const sla::SupportTreeConfig &cfg)
{
double gnd = stree.ground_level;
double H1 = cfg.max_solo_pillar_height_mm;
double H2 = cfg.max_dual_pillar_height_mm;
for (const sla::Head &head : stree.heads()) {
REQUIRE((!head.is_valid() || head.pillar_id != sla::ID_UNSET ||
head.bridge_id != sla::ID_UNSET));
REQUIRE((!head.is_valid() || head.pillar_id != sla::SupportTreeNode::ID_UNSET ||
head.bridge_id != sla::SupportTreeNode::ID_UNSET));
}
for (const sla::Pillar &pillar : stree.pillars()) {

View file

@ -67,16 +67,16 @@ struct SupportByproducts
const constexpr float CLOSING_RADIUS = 0.005f;
void check_support_tree_integrity(const sla::SupportTreeBuilder &stree,
const sla::SupportConfig &cfg);
const sla::SupportTreeConfig &cfg);
void test_supports(const std::string &obj_filename,
const sla::SupportConfig &supportcfg,
const sla::SupportTreeConfig &supportcfg,
const sla::HollowingConfig &hollowingcfg,
const sla::DrainHoles &drainholes,
SupportByproducts &out);
inline void test_supports(const std::string &obj_filename,
const sla::SupportConfig &supportcfg,
const sla::SupportTreeConfig &supportcfg,
SupportByproducts &out)
{
sla::HollowingConfig hcfg;
@ -85,7 +85,7 @@ inline void test_supports(const std::string &obj_filename,
}
inline void test_supports(const std::string &obj_filename,
const sla::SupportConfig &supportcfg = {})
const sla::SupportTreeConfig &supportcfg = {})
{
SupportByproducts byproducts;
test_supports(obj_filename, supportcfg, byproducts);
@ -97,13 +97,13 @@ void export_failed_case(const std::vector<ExPolygons> &support_slices,
void test_support_model_collision(
const std::string &obj_filename,
const sla::SupportConfig &input_supportcfg,
const sla::SupportTreeConfig &input_supportcfg,
const sla::HollowingConfig &hollowingcfg,
const sla::DrainHoles &drainholes);
inline void test_support_model_collision(
const std::string &obj_filename,
const sla::SupportConfig &input_supportcfg = {})
const sla::SupportTreeConfig &input_supportcfg = {})
{
sla::HollowingConfig hcfg;
hcfg.enabled = false;

View file

@ -0,0 +1,99 @@
//#include <catch2/catch.hpp>
//#include <test_utils.hpp>
//#include "libslic3r/TriangleMesh.hpp"
//#include "libslic3r/SLA/SupportTreeBuildsteps.hpp"
//#include "libslic3r/SLA/SupportTreeMesher.hpp"
//TEST_CASE("Test bridge_mesh_intersect on a cube's wall", "[SLABridgeMeshInters]") {
// using namespace Slic3r;
// TriangleMesh cube = make_cube(10., 10., 10.);
// sla::SupportConfig cfg = {}; // use default config
// sla::SupportPoints pts = {{10.f, 5.f, 5.f, float(cfg.head_front_radius_mm), false}};
// sla::SupportableMesh sm{cube, pts, cfg};
// size_t steps = 45;
// SECTION("Bridge is straight horizontal and pointing away from the cube") {
// sla::Bridge bridge(pts[0].pos.cast<double>(), Vec3d{15., 5., 5.},
// pts[0].head_front_radius);
// auto hit = sla::query_hit(sm, bridge);
// REQUIRE(std::isinf(hit.distance()));
// cube.merge(sla::to_triangle_mesh(get_mesh(bridge, steps)));
// cube.require_shared_vertices();
// cube.WriteOBJFile("cube1.obj");
// }
// SECTION("Bridge is tilted down in 45 degrees, pointing away from the cube") {
// sla::Bridge bridge(pts[0].pos.cast<double>(), Vec3d{15., 5., 0.},
// pts[0].head_front_radius);
// auto hit = sla::query_hit(sm, bridge);
// REQUIRE(std::isinf(hit.distance()));
// cube.merge(sla::to_triangle_mesh(get_mesh(bridge, steps)));
// cube.require_shared_vertices();
// cube.WriteOBJFile("cube2.obj");
// }
//}
//TEST_CASE("Test bridge_mesh_intersect on a sphere", "[SLABridgeMeshInters]") {
// using namespace Slic3r;
// TriangleMesh sphere = make_sphere(1.);
// sla::SupportConfig cfg = {}; // use default config
// cfg.head_back_radius_mm = cfg.head_front_radius_mm;
// sla::SupportPoints pts = {{1.f, 0.f, 0.f, float(cfg.head_front_radius_mm), false}};
// sla::SupportableMesh sm{sphere, pts, cfg};
// size_t steps = 45;
// SECTION("Bridge is straight horizontal and pointing away from the sphere") {
// sla::Bridge bridge(pts[0].pos.cast<double>(), Vec3d{2., 0., 0.},
// pts[0].head_front_radius);
// auto hit = sla::query_hit(sm, bridge);
// sphere.merge(sla::to_triangle_mesh(get_mesh(bridge, steps)));
// sphere.require_shared_vertices();
// sphere.WriteOBJFile("sphere1.obj");
// REQUIRE(std::isinf(hit.distance()));
// }
// SECTION("Bridge is tilted down 45 deg and pointing away from the sphere") {
// sla::Bridge bridge(pts[0].pos.cast<double>(), Vec3d{2., 0., -2.},
// pts[0].head_front_radius);
// auto hit = sla::query_hit(sm, bridge);
// sphere.merge(sla::to_triangle_mesh(get_mesh(bridge, steps)));
// sphere.require_shared_vertices();
// sphere.WriteOBJFile("sphere2.obj");
// REQUIRE(std::isinf(hit.distance()));
// }
// SECTION("Bridge is tilted down 90 deg and pointing away from the sphere") {
// sla::Bridge bridge(pts[0].pos.cast<double>(), Vec3d{1., 0., -2.},
// pts[0].head_front_radius);
// auto hit = sla::query_hit(sm, bridge);
// sphere.merge(sla::to_triangle_mesh(get_mesh(bridge, steps)));
// sphere.require_shared_vertices();
// sphere.WriteOBJFile("sphere3.obj");
// REQUIRE(std::isinf(hit.distance()));
// }
//}