2019-11-11 11:41:14 +01:00
|
|
|
#ifndef SLA_SUPPORTTREE_HPP
|
|
|
|
|
#define SLA_SUPPORTTREE_HPP
|
2018-11-02 11:57:57 +01:00
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <Eigen/Geometry>
|
|
|
|
|
|
2019-11-11 11:41:14 +01:00
|
|
|
#include <libslic3r/SLA/Pad.hpp>
|
2020-06-25 13:58:51 +02:00
|
|
|
#include <libslic3r/SLA/IndexedMesh.hpp>
|
2019-11-11 11:41:14 +01:00
|
|
|
#include <libslic3r/SLA/SupportPoint.hpp>
|
|
|
|
|
#include <libslic3r/SLA/JobController.hpp>
|
2019-02-01 16:12:00 +01:00
|
|
|
|
2018-11-02 11:57:57 +01:00
|
|
|
namespace Slic3r {
|
|
|
|
|
|
|
|
|
|
class TriangleMesh;
|
|
|
|
|
class Model;
|
|
|
|
|
class ModelInstance;
|
2018-11-07 15:29:13 +01:00
|
|
|
class ModelObject;
|
2019-06-11 12:40:07 +02:00
|
|
|
class Polygon;
|
2018-11-02 11:57:57 +01:00
|
|
|
class ExPolygon;
|
|
|
|
|
|
2019-06-11 12:40:07 +02:00
|
|
|
using Polygons = std::vector<Polygon>;
|
|
|
|
|
using ExPolygons = std::vector<ExPolygon>;
|
2018-11-02 11:57:57 +01:00
|
|
|
|
|
|
|
|
namespace sla {
|
|
|
|
|
|
2019-09-26 09:42:08 +02:00
|
|
|
enum class PillarConnectionMode
|
|
|
|
|
{
|
2019-01-09 12:21:43 +01:00
|
|
|
zigzag,
|
|
|
|
|
cross,
|
|
|
|
|
dynamic
|
|
|
|
|
};
|
|
|
|
|
|
2020-06-25 13:58:51 +02:00
|
|
|
struct SupportTreeConfig
|
2019-09-26 09:42:08 +02:00
|
|
|
{
|
|
|
|
|
bool enabled = true;
|
|
|
|
|
|
2018-11-02 11:57:57 +01:00
|
|
|
// Radius in mm of the pointing side of the head.
|
|
|
|
|
double head_front_radius_mm = 0.2;
|
|
|
|
|
|
2018-11-07 15:29:13 +01:00
|
|
|
// How much the pinhead has to penetrate the model surface
|
2018-11-19 17:58:08 +01:00
|
|
|
double head_penetration_mm = 0.5;
|
2018-11-07 15:29:13 +01:00
|
|
|
|
2018-11-02 11:57:57 +01:00
|
|
|
// Radius of the back side of the 3d arrow.
|
|
|
|
|
double head_back_radius_mm = 0.5;
|
|
|
|
|
|
|
|
|
|
// Width in mm from the back sphere center to the front sphere center.
|
|
|
|
|
double head_width_mm = 1.0;
|
|
|
|
|
|
2019-01-09 12:21:43 +01:00
|
|
|
// How to connect pillars
|
|
|
|
|
PillarConnectionMode pillar_connection_mode = PillarConnectionMode::dynamic;
|
|
|
|
|
|
2019-02-05 11:16:03 +01:00
|
|
|
// Only generate pillars that can be routed to ground
|
|
|
|
|
bool ground_facing_only = false;
|
|
|
|
|
|
2018-11-23 11:51:45 +01:00
|
|
|
// TODO: unimplemented at the moment. This coefficient will have an impact
|
|
|
|
|
// when bridges and pillars are merged. The resulting pillar should be a bit
|
|
|
|
|
// thicker than the ones merging into it. How much thicker? I don't know
|
|
|
|
|
// but it will be derived from this value.
|
|
|
|
|
double pillar_widening_factor = 0.5;
|
2018-11-02 11:57:57 +01:00
|
|
|
|
|
|
|
|
// Radius in mm of the pillar base.
|
|
|
|
|
double base_radius_mm = 2.0;
|
|
|
|
|
|
|
|
|
|
// The height of the pillar base cone in mm.
|
|
|
|
|
double base_height_mm = 1.0;
|
|
|
|
|
|
|
|
|
|
// The default angle for connecting support sticks and junctions.
|
2019-02-27 11:39:02 +01:00
|
|
|
double bridge_slope = M_PI/4;
|
2018-11-02 11:57:57 +01:00
|
|
|
|
|
|
|
|
// The max length of a bridge in mm
|
2019-03-08 11:39:34 +01:00
|
|
|
double max_bridge_length_mm = 10.0;
|
|
|
|
|
|
|
|
|
|
// The max distance of a pillar to pillar link.
|
|
|
|
|
double max_pillar_link_distance_mm = 10.0;
|
2018-11-14 18:04:43 +01:00
|
|
|
|
|
|
|
|
// The elevation in Z direction upwards. This is the space between the pad
|
|
|
|
|
// and the model object's bounding box bottom.
|
2018-11-16 11:34:19 +01:00
|
|
|
double object_elevation_mm = 10;
|
2019-06-11 17:57:39 +02:00
|
|
|
|
|
|
|
|
// The shortest distance between a pillar base perimeter from the model
|
|
|
|
|
// body. This is only useful when elevation is set to zero.
|
2019-06-11 18:19:58 +02:00
|
|
|
double pillar_base_safety_distance_mm = 0.5;
|
2019-09-24 15:15:49 +02:00
|
|
|
|
2020-03-02 12:43:00 +01:00
|
|
|
unsigned max_bridges_on_pillar = 3;
|
|
|
|
|
|
2019-09-24 15:15:49 +02:00
|
|
|
double head_fullwidth() const {
|
|
|
|
|
return 2 * head_front_radius_mm + head_width_mm +
|
|
|
|
|
2 * head_back_radius_mm - head_penetration_mm;
|
|
|
|
|
}
|
2019-01-02 15:48:38 +01:00
|
|
|
|
2019-03-07 12:01:21 +01:00
|
|
|
// /////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Compile time configuration values (candidates for runtime)
|
|
|
|
|
// /////////////////////////////////////////////////////////////////////////
|
2019-01-02 15:48:38 +01:00
|
|
|
|
2019-03-07 17:17:47 +01:00
|
|
|
// The max Z angle for a normal at which it will get completely ignored.
|
2020-06-19 09:49:50 +02:00
|
|
|
static const double constexpr normal_cutoff_angle = 150.0 * M_PI / 180.0;
|
2019-03-07 17:17:47 +01:00
|
|
|
|
2019-02-27 11:39:02 +01:00
|
|
|
// The shortest distance of any support structure from the model surface
|
2020-06-19 09:49:50 +02:00
|
|
|
static const double constexpr safety_distance_mm = 0.5;
|
2019-03-05 16:28:18 +01:00
|
|
|
|
2020-06-19 09:49:50 +02:00
|
|
|
static const double constexpr max_solo_pillar_height_mm = 15.0;
|
|
|
|
|
static const double constexpr max_dual_pillar_height_mm = 35.0;
|
|
|
|
|
static const double constexpr optimizer_rel_score_diff = 1e-6;
|
|
|
|
|
static const unsigned constexpr optimizer_max_iterations = 1000;
|
|
|
|
|
static const unsigned constexpr pillar_cascade_neighbors = 3;
|
2020-03-02 12:43:00 +01:00
|
|
|
|
2018-11-02 11:57:57 +01:00
|
|
|
};
|
|
|
|
|
|
2020-06-25 13:58:51 +02:00
|
|
|
// TODO: Part of future refactor
|
|
|
|
|
//class SupportConfig {
|
|
|
|
|
// std::optional<SupportTreeConfig> tree_cfg {std::in_place_t{}}; // fill up
|
|
|
|
|
// std::optional<PadConfig> pad_cfg;
|
|
|
|
|
//};
|
|
|
|
|
|
2019-09-26 09:42:08 +02:00
|
|
|
enum class MeshType { Support, Pad };
|
2018-12-11 15:54:54 +01:00
|
|
|
|
2019-09-26 09:42:08 +02:00
|
|
|
struct SupportableMesh
|
|
|
|
|
{
|
2020-06-25 13:58:51 +02:00
|
|
|
IndexedMesh emesh;
|
2019-09-26 09:42:08 +02:00
|
|
|
SupportPoints pts;
|
2020-06-25 13:58:51 +02:00
|
|
|
SupportTreeConfig cfg;
|
|
|
|
|
PadConfig pad_cfg;
|
2019-09-26 09:42:08 +02:00
|
|
|
|
|
|
|
|
explicit SupportableMesh(const TriangleMesh & trmsh,
|
|
|
|
|
const SupportPoints &sp,
|
2020-06-25 13:58:51 +02:00
|
|
|
const SupportTreeConfig &c)
|
2019-09-26 09:42:08 +02:00
|
|
|
: emesh{trmsh}, pts{sp}, cfg{c}
|
|
|
|
|
{}
|
|
|
|
|
|
2020-06-25 13:58:51 +02:00
|
|
|
explicit SupportableMesh(const IndexedMesh &em,
|
2019-09-26 09:42:08 +02:00
|
|
|
const SupportPoints &sp,
|
2020-06-25 13:58:51 +02:00
|
|
|
const SupportTreeConfig &c)
|
2019-09-26 09:42:08 +02:00
|
|
|
: emesh{em}, pts{sp}, cfg{c}
|
|
|
|
|
{}
|
|
|
|
|
};
|
2018-11-02 11:57:57 +01:00
|
|
|
|
|
|
|
|
/// The class containing mesh data for the generated supports.
|
2019-09-26 09:42:08 +02:00
|
|
|
class SupportTree
|
|
|
|
|
{
|
|
|
|
|
JobController m_ctl;
|
2018-11-02 11:57:57 +01:00
|
|
|
public:
|
2019-09-26 09:42:08 +02:00
|
|
|
using UPtr = std::unique_ptr<SupportTree>;
|
2019-07-30 17:57:07 +02:00
|
|
|
|
2019-09-26 09:42:08 +02:00
|
|
|
static UPtr create(const SupportableMesh &input,
|
|
|
|
|
const JobController &ctl = {});
|
2018-11-02 11:57:57 +01:00
|
|
|
|
2019-09-26 09:42:08 +02:00
|
|
|
virtual ~SupportTree() = default;
|
2018-11-02 11:57:57 +01:00
|
|
|
|
2019-09-26 09:42:08 +02:00
|
|
|
virtual const TriangleMesh &retrieve_mesh(MeshType meshtype) const = 0;
|
2018-11-02 11:57:57 +01:00
|
|
|
|
2019-09-26 09:42:08 +02:00
|
|
|
/// Adding the "pad" under the supports.
|
2019-06-11 12:40:07 +02:00
|
|
|
/// modelbase will be used according to the embed_object flag in PoolConfig.
|
2019-09-26 09:42:08 +02:00
|
|
|
/// If set, the plate will be interpreted as the model's intrinsic pad.
|
2019-06-11 12:40:07 +02:00
|
|
|
/// Otherwise, the modelbase will be unified with the base plate calculated
|
|
|
|
|
/// from the supports.
|
2019-09-26 09:42:08 +02:00
|
|
|
virtual const TriangleMesh &add_pad(const ExPolygons &modelbase,
|
|
|
|
|
const PadConfig & pcfg) = 0;
|
|
|
|
|
|
|
|
|
|
virtual void remove_pad() = 0;
|
|
|
|
|
|
|
|
|
|
std::vector<ExPolygons> slice(const std::vector<float> &,
|
|
|
|
|
float closing_radius) const;
|
|
|
|
|
|
|
|
|
|
void retrieve_full_mesh(TriangleMesh &outmesh) const;
|
|
|
|
|
|
|
|
|
|
const JobController &ctl() const { return m_ctl; }
|
2018-11-02 11:57:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // SLASUPPORTTREE_HPP
|