Fix endless loop in pinhead creation.

* Headless stick penetration value from global cfg
* eliminate warnings
This commit is contained in:
tamasmeszaros 2019-10-03 17:18:03 +02:00
parent 4569a6026a
commit 2edd5abf06
4 changed files with 14 additions and 5 deletions

View file

@ -171,6 +171,9 @@ Head::Head(double r_big_mm,
, width_mm(length_mm)
, penetration_mm(penetration)
{
assert(width_mm > 0.);
assert(r_back_mm > 0.);
assert(r_pin_mm > 0.);
// We create two spheres which will be connected with a robe that fits
// both circles perfectly.

View file

@ -311,7 +311,7 @@ public:
if (m_pillars.capacity() < m_heads.size())
m_pillars.reserve(m_heads.size() * 10);
assert(headid >= 0 && headid < m_head_indices.size());
assert(headid >= 0 && size_t(headid) < m_head_indices.size());
Head &head = m_heads[m_head_indices[size_t(headid)]];
m_pillars.emplace_back(head, std::forward<Args>(args)...);
@ -328,7 +328,7 @@ public:
void add_pillar_base(long pid, double baseheight = 3, double radius = 2)
{
std::lock_guard<Mutex> lk(m_mutex);
assert(pid >= 0 && pid < m_pillars.size());
assert(pid >= 0 && size_t(pid) < m_pillars.size());
m_pillars[size_t(pid)].add_base(baseheight, radius);
}
@ -398,7 +398,7 @@ public:
const Bridge& add_bridge(long headid, const Vec3d &endp, size_t s = 45)
{
std::lock_guard<Mutex> lk(m_mutex);
assert(headid >= 0 && headid < m_head_indices.size());
assert(headid >= 0 && size_t(headid) < m_head_indices.size());
Head &h = m_heads[m_head_indices[size_t(headid)]];
m_bridges.emplace_back(h.junction_point(), endp, h.r_back_mm, s);

View file

@ -1096,6 +1096,11 @@ void SupportTreeBuildsteps::routing_to_model()
double dist = distance(endp, hitp) + m_cfg.head_penetration_mm;
double w = dist - 2 * head.r_pin_mm - head.r_back_mm;
if (w < 0.) {
BOOST_LOG_TRIVIAL(error) << "Pinhead width is negative!";
w = 0.;
}
Head tailhead(head.r_back_mm,
head.r_pin_mm,
w,
@ -1348,7 +1353,7 @@ void SupportTreeBuildsteps::routing_headless()
m_thr();
const auto R = double(m_support_pts[i].head_front_radius);
const double HWIDTH_MM = R/3;
const double HWIDTH_MM = m_cfg.head_penetration_mm;
// Exact support position
Vec3d sph = m_support_pts[i].pos.cast<double>();

View file

@ -260,7 +260,7 @@ void test_support_model_collision(
// Set head penetration to a small negative value which should ensure that
// the supports will not touch the model body.
supportcfg.head_penetration_mm = -1.; // 1 mm should be more than enough
supportcfg.head_penetration_mm = -0.1;
test_supports(obj_filename, supportcfg, byproducts);
@ -277,6 +277,7 @@ void test_support_model_collision(
const ExPolygons &mod_slice = byproducts.model_slices[n];
Polygons intersections = intersection(sup_slice, mod_slice);
notouch = notouch && intersections.empty();
}