mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-22 06:04:01 -06:00
Fix concave hull having holes.
This commit is contained in:
parent
a6a7303e25
commit
175b6fd9f5
6 changed files with 292 additions and 201 deletions
53
src/libslic3r/SLA/ConcaveHull.hpp
Normal file
53
src/libslic3r/SLA/ConcaveHull.hpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
#ifndef CONCAVEHULL_HPP
|
||||
#define CONCAVEHULL_HPP
|
||||
|
||||
#include <libslic3r/ExPolygon.hpp>
|
||||
|
||||
namespace Slic3r {
|
||||
namespace sla {
|
||||
|
||||
inline Polygons get_contours(const ExPolygons &poly)
|
||||
{
|
||||
Polygons ret; ret.reserve(poly.size());
|
||||
for (const ExPolygon &p : poly) ret.emplace_back(p.contour);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
using ThrowOnCancel = std::function<void()>;
|
||||
|
||||
/// A fake concave hull that is constructed by connecting separate shapes
|
||||
/// 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...)
|
||||
class ConcaveHull {
|
||||
Polygons m_polys;
|
||||
|
||||
static Point centroid(const Points& pp);
|
||||
|
||||
static inline Point centroid(const Polygon &poly) { return poly.centroid(); }
|
||||
|
||||
Points calculate_centroids() const;
|
||||
|
||||
void merge_polygons();
|
||||
|
||||
void add_connector_rectangles(const Points ¢roids,
|
||||
coord_t max_dist,
|
||||
ThrowOnCancel thr);
|
||||
public:
|
||||
|
||||
ConcaveHull(const ExPolygons& polys, double merge_dist, ThrowOnCancel thr)
|
||||
: ConcaveHull{to_polygons(polys), merge_dist, thr} {}
|
||||
|
||||
ConcaveHull(const Polygons& polys, double mergedist, ThrowOnCancel thr);
|
||||
|
||||
const Polygons & polygons() const { return m_polys; }
|
||||
|
||||
ExPolygons to_expolygons() const;
|
||||
};
|
||||
|
||||
ExPolygons offset_waffle_style_ex(const ConcaveHull &ccvhull, coord_t delta);
|
||||
Polygons offset_waffle_style(const ConcaveHull &polys, coord_t delta);
|
||||
|
||||
}} // namespace Slic3r::sla
|
||||
#endif // CONCAVEHULL_HPP
|
Loading…
Add table
Add a link
Reference in a new issue