2018-11-02 10:57:57 +00:00
|
|
|
#ifndef SLASUPPORTTREE_HPP
|
|
|
|
#define SLASUPPORTTREE_HPP
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
|
|
|
#include <Eigen/Geometry>
|
|
|
|
|
2019-02-01 15:12:00 +00:00
|
|
|
#include "SLACommon.hpp"
|
2019-09-26 07:42:08 +00:00
|
|
|
#include "SLAPad.hpp"
|
2019-02-01 15:12:00 +00:00
|
|
|
|
2018-11-02 10:57:57 +00:00
|
|
|
namespace Slic3r {
|
|
|
|
|
|
|
|
class TriangleMesh;
|
|
|
|
class Model;
|
|
|
|
class ModelInstance;
|
2018-11-07 14:29:13 +00:00
|
|
|
class ModelObject;
|
2019-06-11 10:40:07 +00:00
|
|
|
class Polygon;
|
2018-11-02 10:57:57 +00:00
|
|
|
class ExPolygon;
|
|
|
|
|
2019-06-11 10:40:07 +00:00
|
|
|
using Polygons = std::vector<Polygon>;
|
|
|
|
using ExPolygons = std::vector<ExPolygon>;
|
2018-11-02 10:57:57 +00:00
|
|
|
|
|
|
|
namespace sla {
|
|
|
|
|
2019-09-26 07:42:08 +00:00
|
|
|
enum class PillarConnectionMode
|
|
|
|
{
|
2019-01-09 11:21:43 +00:00
|
|
|
zigzag,
|
|
|
|
cross,
|
|
|
|
dynamic
|
|
|
|
};
|
|
|
|
|
2019-09-26 07:42:08 +00:00
|
|
|
struct SupportConfig
|
|
|
|
{
|
|
|
|
bool enabled = true;
|
|
|
|
|
2018-11-02 10:57:57 +00:00
|
|
|
// Radius in mm of the pointing side of the head.
|
|
|
|
double head_front_radius_mm = 0.2;
|
|
|
|
|
2018-11-07 14:29:13 +00:00
|
|
|
// How much the pinhead has to penetrate the model surface
|
2018-11-19 16:58:08 +00:00
|
|
|
double head_penetration_mm = 0.5;
|
2018-11-07 14:29:13 +00:00
|
|
|
|
2018-11-02 10:57:57 +00: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 11:21:43 +00:00
|
|
|
// How to connect pillars
|
|
|
|
PillarConnectionMode pillar_connection_mode = PillarConnectionMode::dynamic;
|
|
|
|
|
2019-02-05 10:16:03 +00:00
|
|
|
// Only generate pillars that can be routed to ground
|
|
|
|
bool ground_facing_only = false;
|
|
|
|
|
2018-11-23 10:51:45 +00: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 10:57:57 +00: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 10:39:02 +00:00
|
|
|
double bridge_slope = M_PI/4;
|
2018-11-02 10:57:57 +00:00
|
|
|
|
|
|
|
// The max length of a bridge in mm
|
2019-03-08 10:39:34 +00: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 17:04:43 +00: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 10:34:19 +00:00
|
|
|
double object_elevation_mm = 10;
|
2019-06-11 15:57:39 +00: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 16:19:58 +00:00
|
|
|
double pillar_base_safety_distance_mm = 0.5;
|
2019-09-24 13:15:49 +00: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 14:48:38 +00:00
|
|
|
|
2019-03-07 11:01:21 +00:00
|
|
|
// /////////////////////////////////////////////////////////////////////////
|
|
|
|
// Compile time configuration values (candidates for runtime)
|
|
|
|
// /////////////////////////////////////////////////////////////////////////
|
2019-03-05 15:28:18 +00:00
|
|
|
|
2019-03-07 16:17:47 +00:00
|
|
|
// The max Z angle for a normal at which it will get completely ignored.
|
|
|
|
static const double normal_cutoff_angle;
|
|
|
|
|
2019-03-07 11:01:21 +00:00
|
|
|
// The shortest distance of any support structure from the model surface
|
|
|
|
static const double safety_distance_mm;
|
2019-03-05 15:28:18 +00:00
|
|
|
|
2019-03-07 11:01:21 +00:00
|
|
|
static const double max_solo_pillar_height_mm;
|
|
|
|
static const double max_dual_pillar_height_mm;
|
|
|
|
static const double optimizer_rel_score_diff;
|
|
|
|
static const unsigned optimizer_max_iterations;
|
|
|
|
static const unsigned pillar_cascade_neighbors;
|
2019-03-07 16:17:47 +00:00
|
|
|
static const unsigned max_bridges_on_pillar;
|
2018-11-02 10:57:57 +00:00
|
|
|
};
|
|
|
|
|
2019-09-26 07:42:08 +00:00
|
|
|
enum class MeshType { Support, Pad };
|
2018-12-11 14:54:54 +00:00
|
|
|
|
2018-11-02 10:57:57 +00:00
|
|
|
/// A Control structure for the support calculation. Consists of the status
|
|
|
|
/// indicator callback and the stop condition predicate.
|
2019-09-26 07:42:08 +00:00
|
|
|
struct JobController
|
|
|
|
{
|
|
|
|
using StatusFn = std::function<void(unsigned, const std::string&)>;
|
|
|
|
using StopCond = std::function<bool(void)>;
|
|
|
|
using CancelFn = std::function<void(void)>;
|
|
|
|
|
2018-11-16 15:44:44 +00:00
|
|
|
// This will signal the status of the calculation to the front-end
|
2019-09-26 07:42:08 +00:00
|
|
|
StatusFn statuscb = [](unsigned, const std::string&){};
|
|
|
|
|
2018-11-16 15:44:44 +00:00
|
|
|
// Returns true if the calculation should be aborted.
|
2019-09-26 07:42:08 +00:00
|
|
|
StopCond stopcondition = [](){ return false; };
|
|
|
|
|
2018-11-16 15:44:44 +00:00
|
|
|
// Similar to cancel callback. This should check the stop condition and
|
|
|
|
// if true, throw an appropriate exception. (TriangleMeshSlicer needs this)
|
|
|
|
// consider it a hard abort. stopcondition is permits the algorithm to
|
|
|
|
// terminate itself
|
2019-09-26 07:42:08 +00:00
|
|
|
CancelFn cancelfn = [](){};
|
2018-11-02 10:57:57 +00:00
|
|
|
};
|
|
|
|
|
2019-09-26 07:42:08 +00:00
|
|
|
struct SupportableMesh
|
|
|
|
{
|
|
|
|
EigenMesh3D emesh;
|
|
|
|
SupportPoints pts;
|
|
|
|
SupportConfig cfg;
|
|
|
|
|
|
|
|
explicit SupportableMesh(const TriangleMesh & trmsh,
|
|
|
|
const SupportPoints &sp,
|
|
|
|
const SupportConfig &c)
|
|
|
|
: emesh{trmsh}, pts{sp}, cfg{c}
|
|
|
|
{}
|
|
|
|
|
|
|
|
explicit SupportableMesh(const EigenMesh3D &em,
|
|
|
|
const SupportPoints &sp,
|
|
|
|
const SupportConfig &c)
|
|
|
|
: emesh{em}, pts{sp}, cfg{c}
|
|
|
|
{}
|
|
|
|
};
|
2018-11-02 10:57:57 +00:00
|
|
|
|
|
|
|
/// The class containing mesh data for the generated supports.
|
2019-09-26 07:42:08 +00:00
|
|
|
class SupportTree
|
|
|
|
{
|
|
|
|
JobController m_ctl;
|
2018-11-02 10:57:57 +00:00
|
|
|
public:
|
2019-09-26 07:42:08 +00:00
|
|
|
using UPtr = std::unique_ptr<SupportTree>;
|
2019-09-24 13:15:49 +00:00
|
|
|
|
2019-09-26 07:42:08 +00:00
|
|
|
static UPtr create(const SupportableMesh &input,
|
|
|
|
const JobController &ctl = {});
|
2018-11-02 10:57:57 +00:00
|
|
|
|
2019-09-26 07:42:08 +00:00
|
|
|
virtual ~SupportTree() = default;
|
2018-11-02 10:57:57 +00:00
|
|
|
|
2019-09-26 07:42:08 +00:00
|
|
|
virtual const TriangleMesh &retrieve_mesh(MeshType meshtype) const = 0;
|
2018-11-02 10:57:57 +00:00
|
|
|
|
2019-09-26 07:42:08 +00:00
|
|
|
/// Adding the "pad" under the supports.
|
2019-06-11 10:40:07 +00:00
|
|
|
/// modelbase will be used according to the embed_object flag in PoolConfig.
|
2019-09-26 07:42:08 +00:00
|
|
|
/// If set, the plate will be interpreted as the model's intrinsic pad.
|
2019-06-11 10:40:07 +00:00
|
|
|
/// Otherwise, the modelbase will be unified with the base plate calculated
|
|
|
|
/// from the supports.
|
2019-09-26 07:42:08 +00: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 10:57:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SLASUPPORTTREE_HPP
|