2018-12-07 13:10:16 +00:00
|
|
|
#ifndef SLAAUTOSUPPORTS_HPP_
|
|
|
|
#define SLAAUTOSUPPORTS_HPP_
|
|
|
|
|
|
|
|
#include <libslic3r/Point.hpp>
|
2018-12-07 14:24:50 +00:00
|
|
|
#include <libslic3r/TriangleMesh.hpp>
|
2019-02-01 15:12:00 +00:00
|
|
|
#include <libslic3r/SLA/SLACommon.hpp>
|
2018-12-07 13:10:16 +00:00
|
|
|
|
2018-12-22 09:55:15 +00:00
|
|
|
// #define SLA_AUTOSUPPORTS_DEBUG
|
2018-12-07 13:10:16 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
|
|
|
class SLAAutoSupports {
|
|
|
|
public:
|
|
|
|
struct Config {
|
|
|
|
float density_at_horizontal;
|
|
|
|
float density_at_45;
|
|
|
|
float minimal_z;
|
2019-01-30 07:26:23 +00:00
|
|
|
///////////////
|
|
|
|
float support_force = 30; // a force one point can support (arbitrary force unit)
|
|
|
|
float tear_pressure = 1; // pressure that the display exerts (the force unit per mm2)
|
2018-12-07 13:10:16 +00:00
|
|
|
};
|
|
|
|
|
2019-01-30 07:26:23 +00:00
|
|
|
SLAAutoSupports(const TriangleMesh& mesh, const sla::EigenMesh3D& emesh, const std::vector<ExPolygons>& slices,
|
|
|
|
const std::vector<float>& heights, const Config& config, std::function<void(void)> throw_on_cancel);
|
|
|
|
const std::vector<sla::SupportPoint>& output() { return m_output; }
|
2018-12-07 13:10:16 +00:00
|
|
|
|
|
|
|
private:
|
2019-01-30 07:26:23 +00:00
|
|
|
std::vector<sla::SupportPoint> m_output;
|
2018-12-21 11:35:20 +00:00
|
|
|
|
2018-12-22 09:55:15 +00:00
|
|
|
#ifdef SLA_AUTOSUPPORTS_DEBUG
|
2018-12-21 11:35:20 +00:00
|
|
|
void output_expolygons(const ExPolygons& expolys, std::string filename) const;
|
2019-01-30 07:26:23 +00:00
|
|
|
void output_structures() const;
|
2019-02-04 07:40:20 +00:00
|
|
|
#endif // SLA_AUTOSUPPORTS_DEBUG
|
2018-12-07 13:10:16 +00:00
|
|
|
|
|
|
|
SLAAutoSupports::Config m_config;
|
2019-01-30 07:26:23 +00:00
|
|
|
|
|
|
|
struct Structure {
|
|
|
|
Structure(const ExPolygon& poly, float h) : height(h), unique_id(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch())) {
|
|
|
|
polygon = &poly;
|
|
|
|
}
|
|
|
|
const ExPolygon* polygon = nullptr;
|
|
|
|
std::vector<const Structure*> structures_below;
|
|
|
|
float height = 0;
|
|
|
|
float supports_force = 0.f;
|
|
|
|
std::chrono::milliseconds unique_id;
|
|
|
|
};
|
|
|
|
std::vector<Structure> m_structures_old;
|
|
|
|
std::vector<Structure> m_structures_new;
|
|
|
|
float m_supports_force_total = 0.f;
|
|
|
|
|
|
|
|
void process(const std::vector<ExPolygons>& slices, const std::vector<float>& heights);
|
|
|
|
void add_point(const Point& point, Structure& structure, bool island = false);
|
|
|
|
void uniformly_cover(const ExPolygon& island, Structure& structure, bool is_new_island = false, bool just_one = false);
|
|
|
|
void project_onto_mesh(std::vector<sla::SupportPoint>& points) const;
|
|
|
|
|
|
|
|
|
2018-12-22 10:21:21 +00:00
|
|
|
std::function<void(void)> m_throw_on_cancel;
|
2019-02-04 08:50:25 +00:00
|
|
|
const sla::EigenMesh3D& m_emesh;
|
2018-12-07 13:10:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Slic3r
|
|
|
|
|
|
|
|
|
|
|
|
#endif // SLAAUTOSUPPORTS_HPP_
|