Fixing zero elevation bug when concave hull overlap was not detected.
Backported from tm_perf_optims
This commit is contained in:
parent
7f33e23fbb
commit
320f964847
@ -320,6 +320,9 @@ using FloatingOnly = enable_if_t<std::is_floating_point<T>::value, O>;
|
||||
template<class T, class O = T>
|
||||
using ScaledCoordOnly = enable_if_t<is_scaled_coord<T>::value, O>;
|
||||
|
||||
template<class T, class O = T>
|
||||
using IntegerOnly = enable_if_t<std::is_integral<T>::value, O>;
|
||||
|
||||
template<class T, class O = T>
|
||||
using ArithmeticOnly = enable_if_t<std::is_arithmetic<T>::value, O>;
|
||||
|
||||
@ -384,6 +387,13 @@ unscaled(const Eigen::Matrix<Tin, N, EigenArgs...> &v) noexcept
|
||||
return v.template cast<Tout>() * SCALING_FACTOR;
|
||||
}
|
||||
|
||||
template<class T> inline std::vector<T> reserve_vector(size_t capacity)
|
||||
{
|
||||
std::vector<T> ret;
|
||||
ret.reserve(capacity);
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // MTUTILS_HPP
|
||||
|
@ -591,8 +591,7 @@ inline Point centroid(const Polygon& poly) {
|
||||
/// with explicit bridges. Bridges are generated from each shape's centroid
|
||||
/// to the center of the "scene" which is the centroid calculated from the shape
|
||||
/// centroids (a star is created...)
|
||||
Polygons concave_hull(const Polygons& polys, double max_dist_mm = 50,
|
||||
ThrowOnCancel throw_on_cancel = [](){})
|
||||
Polygons concave_hull(const Polygons& polys, double maxd_mm, ThrowOnCancel thr)
|
||||
{
|
||||
namespace bgi = boost::geometry::index;
|
||||
using SpatElement = std::pair<Point, unsigned>;
|
||||
@ -600,7 +599,7 @@ Polygons concave_hull(const Polygons& polys, double max_dist_mm = 50,
|
||||
|
||||
if(polys.empty()) return Polygons();
|
||||
|
||||
const double max_dist = scaled(max_dist_mm);
|
||||
const double max_dist = scaled(maxd_mm);
|
||||
|
||||
Polygons punion = unify(polys); // could be redundant
|
||||
|
||||
@ -624,10 +623,10 @@ Polygons concave_hull(const Polygons& polys, double max_dist_mm = 50,
|
||||
idx = 0;
|
||||
std::transform(centroids.begin(), centroids.end(),
|
||||
std::back_inserter(punion),
|
||||
[¢roids, &ctrindex, cc, max_dist, &idx, throw_on_cancel]
|
||||
[¢roids, &ctrindex, cc, max_dist, &idx, thr]
|
||||
(const Point& c)
|
||||
{
|
||||
throw_on_cancel();
|
||||
thr();
|
||||
double dx = x(c) - x(cc), dy = y(c) - y(cc);
|
||||
double l = std::sqrt(dx * dx + dy * dy);
|
||||
double nx = dx / l, ny = dy / l;
|
||||
|
@ -41,6 +41,9 @@ void breakstick_holes(ExPolygon &poly,
|
||||
double stick_width,
|
||||
double penetration = 0.0);
|
||||
|
||||
Polygons concave_hull(const Polygons& polys, double max_dist_mm = 50,
|
||||
ThrowOnCancel throw_on_cancel = [](){});
|
||||
|
||||
struct PoolConfig {
|
||||
double min_wall_thickness_mm = 2;
|
||||
double min_wall_height_mm = 5;
|
||||
|
@ -618,15 +618,25 @@ struct Pad {
|
||||
}
|
||||
}
|
||||
|
||||
ExPolygons concaveh = offset_ex(
|
||||
concave_hull(basep, pcfg.max_merge_distance_mm, thr),
|
||||
scaled<float>(pcfg.min_wall_thickness_mm));
|
||||
|
||||
// Punching the breaksticks across the offsetted polygon perimeters
|
||||
ExPolygons pad_stickholes; pad_stickholes.reserve(modelbase.size());
|
||||
auto pad_stickholes = reserve_vector<ExPolygon>(modelbase.size());
|
||||
for(auto& poly : modelbase_offs) {
|
||||
|
||||
bool overlap = false;
|
||||
for (const ExPolygon &p : concaveh)
|
||||
overlap = overlap || poly.overlaps(p);
|
||||
|
||||
auto bb = poly.contour.bounding_box();
|
||||
bb.offset(scaled<float>(pcfg.min_wall_thickness_mm));
|
||||
|
||||
std::vector<BoxIndexEl> qres =
|
||||
bindex.query(poly.contour.bounding_box(),
|
||||
BoxIndex::qtIntersects);
|
||||
|
||||
if (!qres.empty()) {
|
||||
bindex.query(bb, BoxIndex::qtIntersects);
|
||||
|
||||
if (!qres.empty() || overlap) {
|
||||
|
||||
// The model silhouette polygon 'poly' HAS an intersection
|
||||
// with the support silhouettes. Include this polygon
|
||||
|
Loading…
Reference in New Issue
Block a user