Fix failing sla tree tests

Try to increase number of rays in Beam to prevent colisions


Put back threshold for intersections with model in sla tree tests 


Increase safety distance for branching tree instead of increasing rays
This commit is contained in:
tamasmeszaros 2022-05-17 10:52:52 +02:00
parent fd8fd77077
commit 0a3b17f940
4 changed files with 61 additions and 50 deletions

View File

@ -120,7 +120,7 @@ bool BranchingTreeBuilder::add_bridge(const branchingtree::Node &from,
double fromR = get_radius(from), toR = get_radius(to); double fromR = get_radius(from), toR = get_radius(to);
Beam beam{Ball{fromd, fromR}, Ball{tod, toR}}; Beam beam{Ball{fromd, fromR}, Ball{tod, toR}};
auto hit = beam_mesh_hit(ex_tbb, m_sm.emesh, beam, auto hit = beam_mesh_hit(ex_tbb, m_sm.emesh, beam,
m_sm.cfg.safety_distance_mm); 2 * m_sm.cfg.safety_distance_mm);
bool ret = hit.distance() > (tod - fromd).norm(); bool ret = hit.distance() > (tod - fromd).norm();
@ -140,7 +140,8 @@ bool BranchingTreeBuilder::add_merger(const branchingtree::Node &node,
double closestR = get_radius(closest); double closestR = get_radius(closest);
Beam beam1{Ball{from1d, nodeR}, Ball{tod, mergeR}}; Beam beam1{Ball{from1d, nodeR}, Ball{tod, mergeR}};
Beam beam2{Ball{from2d, closestR}, Ball{tod, mergeR}}; Beam beam2{Ball{from2d, closestR}, Ball{tod, mergeR}};
auto sd = m_sm.cfg.safety_distance_mm;
auto sd = 2 * m_sm.cfg.safety_distance_mm;
auto hit1 = beam_mesh_hit(ex_tbb, m_sm.emesh, beam1, sd); auto hit1 = beam_mesh_hit(ex_tbb, m_sm.emesh, beam1, sd);
auto hit2 = beam_mesh_hit(ex_tbb, m_sm.emesh, beam2, sd); auto hit2 = beam_mesh_hit(ex_tbb, m_sm.emesh, beam2, sd);
@ -178,7 +179,9 @@ bool BranchingTreeBuilder::add_mesh_bridge(const branchingtree::Node &from,
m_builder.add_diffbridge(fromj.pos, anchor->junction_point(), fromj.r, m_builder.add_diffbridge(fromj.pos, anchor->junction_point(), fromj.r,
anchor->r_back_mm); anchor->r_back_mm);
if (!m_sm.cfg.ground_facing_only) { // Easter egg, to omit the anchors
m_builder.add_anchor(*anchor); m_builder.add_anchor(*anchor);
}
build_subtree(from.id); build_subtree(from.id);
} }

View File

@ -57,7 +57,11 @@ sla::SupportTreeConfig make_support_cfg(const SLAPrintObjectConfig& c)
scfg.max_bridge_length_mm = c.support_max_bridge_length.getFloat(); scfg.max_bridge_length_mm = c.support_max_bridge_length.getFloat();
scfg.max_pillar_link_distance_mm = c.support_max_pillar_link_distance.getFloat(); scfg.max_pillar_link_distance_mm = c.support_max_pillar_link_distance.getFloat();
scfg.pillar_connection_mode = c.support_pillar_connection_mode.value; scfg.pillar_connection_mode = c.support_pillar_connection_mode.value;
if (scfg.tree_type != sla::SupportTreeType::Branching) {
// Branching tree is all about routing to model body, it doesn't support
// this option.
scfg.ground_facing_only = c.support_buildplate_only.getBool(); scfg.ground_facing_only = c.support_buildplate_only.getBool();
}
scfg.pillar_widening_factor = c.support_pillar_widening_factor.getFloat(); scfg.pillar_widening_factor = c.support_pillar_widening_factor.getFloat();
scfg.base_radius_mm = 0.5*c.support_base_diameter.getFloat(); scfg.base_radius_mm = 0.5*c.support_base_diameter.getFloat();
scfg.base_height_mm = c.support_base_height.getFloat(); scfg.base_height_mm = c.support_base_height.getFloat();

View File

@ -6,7 +6,8 @@
#include <iomanip> #include <iomanip>
void test_support_model_collision(const std::string &obj_filename, void test_support_model_collision(
const std::string &obj_filename,
const sla::SupportTreeConfig &input_supportcfg, const sla::SupportTreeConfig &input_supportcfg,
const sla::HollowingConfig &hollowingcfg, const sla::HollowingConfig &hollowingcfg,
const sla::DrainHoles &drainholes) const sla::DrainHoles &drainholes)
@ -15,6 +16,9 @@ void test_support_model_collision(const std::string &obj_filename,
sla::SupportTreeConfig supportcfg = input_supportcfg; sla::SupportTreeConfig supportcfg = input_supportcfg;
// Ensure that there are no anchors which would pierce the model.
supportcfg.ground_facing_only = true;
// Set head penetration to a small negative value which should ensure that // Set head penetration to a small negative value which should ensure that
// the supports will not touch the model body. // the supports will not touch the model body.
supportcfg.head_penetration_mm = -0.2; supportcfg.head_penetration_mm = -0.2;
@ -23,15 +27,15 @@ void test_support_model_collision(const std::string &obj_filename,
// Slice the support mesh given the slice grid of the model. // Slice the support mesh given the slice grid of the model.
std::vector<ExPolygons> support_slices = std::vector<ExPolygons> support_slices =
sla::slice(byproducts.supporttree.retrieve_mesh(sla::MeshType::Support), sla::slice(byproducts.suptree_builder.retrieve_mesh(sla::MeshType::Support),
byproducts.supporttree.retrieve_mesh(sla::MeshType::Pad), byproducts.suptree_builder.retrieve_mesh(sla::MeshType::Pad),
byproducts.slicegrid, CLOSING_RADIUS, {}); byproducts.slicegrid, CLOSING_RADIUS, {});
// The slices originate from the same slice grid so the numbers must match // The slices originate from the same slice grid so the numbers must match
bool support_mesh_is_empty = bool support_mesh_is_empty =
byproducts.supporttree.retrieve_mesh(sla::MeshType::Pad).empty() && byproducts.suptree_builder.retrieve_mesh(sla::MeshType::Pad).empty() &&
byproducts.supporttree.retrieve_mesh(sla::MeshType::Support).empty(); byproducts.suptree_builder.retrieve_mesh(sla::MeshType::Support).empty();
if (support_mesh_is_empty) if (support_mesh_is_empty)
REQUIRE(support_slices.empty()); REQUIRE(support_slices.empty());
@ -80,7 +84,7 @@ void export_failed_case(const std::vector<ExPolygons> &support_slices, const Sup
if (do_export_stl) { if (do_export_stl) {
indexed_triangle_set its; indexed_triangle_set its;
byproducts.supporttree.retrieve_full_mesh(its); byproducts.suptree_builder.retrieve_full_mesh(its);
TriangleMesh m{its}; TriangleMesh m{its};
m.merge(byproducts.input_mesh); m.merge(byproducts.input_mesh);
m.WriteOBJFile((Catch::getResultCapture().getCurrentTestName() + "_" + m.WriteOBJFile((Catch::getResultCapture().getCurrentTestName() + "_" +
@ -119,10 +123,10 @@ void test_supports(const std::string &obj_filename,
// is the input of the support point and support mesh generators // is the input of the support point and support mesh generators
AABBMesh emesh{mesh}; AABBMesh emesh{mesh};
#ifdef SLIC3R_HOLE_RAYCASTER #ifdef SLIC3R_HOLE_RAYCASTER
if (hollowingcfg.enabled) if (hollowingcfg.enabled)
emesh.load_holes(drainholes); emesh.load_holes(drainholes);
#endif #endif
// TODO: do the cgal hole cutting... // TODO: do the cgal hole cutting...
@ -187,7 +191,7 @@ void test_supports(const std::string &obj_filename,
// Move out the support tree into the byproducts, we can examine it further // Move out the support tree into the byproducts, we can examine it further
// in various tests. // in various tests.
out.obj_fname = std::move(obj_filename); out.obj_fname = std::move(obj_filename);
out.supporttree = std::move(treebuilder); out.suptree_builder = std::move(treebuilder);
out.input_mesh = std::move(mesh); out.input_mesh = std::move(mesh);
} }

View File

@ -60,7 +60,7 @@ struct SupportByproducts
std::string obj_fname; std::string obj_fname;
std::vector<float> slicegrid; std::vector<float> slicegrid;
std::vector<ExPolygons> model_slices; std::vector<ExPolygons> model_slices;
sla::SupportTreeBuilder supporttree; sla::SupportTreeBuilder suptree_builder;
TriangleMesh input_mesh; TriangleMesh input_mesh;
}; };