Adding checkbox for disabling support generation (still having pad generation)
This commit is contained in:
parent
7efadfae1c
commit
d28b61f8a3
8 changed files with 72 additions and 24 deletions
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
// TODO: these classes are untested
|
|
||||||
|
|
||||||
/// Handy little spin mutex for the cached meshes.
|
/// Handy little spin mutex for the cached meshes.
|
||||||
/// Implements the "Lockable" concept
|
/// Implements the "Lockable" concept
|
||||||
class SpinMutex {
|
class SpinMutex {
|
||||||
|
|
|
@ -2445,6 +2445,14 @@ void PrintConfigDef::init_sla_params()
|
||||||
def = this->add("sla_print_settings_id", coString);
|
def = this->add("sla_print_settings_id", coString);
|
||||||
def->default_value = new ConfigOptionString("");
|
def->default_value = new ConfigOptionString("");
|
||||||
|
|
||||||
|
def = this->add("supports_enable", coBool);
|
||||||
|
def->label = L("Generate supports");
|
||||||
|
def->category = L("Supports");
|
||||||
|
def->tooltip = L("Generate supports for the models");
|
||||||
|
def->sidetext = L("");
|
||||||
|
def->cli = "";
|
||||||
|
def->default_value = new ConfigOptionBool(true);
|
||||||
|
|
||||||
def = this->add("support_head_front_radius", coFloat);
|
def = this->add("support_head_front_radius", coFloat);
|
||||||
def->label = L("Support head front radius");
|
def->label = L("Support head front radius");
|
||||||
def->category = L("Supports");
|
def->category = L("Supports");
|
||||||
|
|
|
@ -904,6 +904,9 @@ class SLAPrintObjectConfig : public StaticPrintConfig
|
||||||
public:
|
public:
|
||||||
ConfigOptionFloat layer_height;
|
ConfigOptionFloat layer_height;
|
||||||
|
|
||||||
|
// Enabling or disabling support creation
|
||||||
|
ConfigOptionBool supports_enable;
|
||||||
|
|
||||||
// Radius in mm of the pointing side of the head.
|
// Radius in mm of the pointing side of the head.
|
||||||
ConfigOptionFloat support_head_front_radius /*= 0.2*/;
|
ConfigOptionFloat support_head_front_radius /*= 0.2*/;
|
||||||
|
|
||||||
|
@ -942,16 +945,27 @@ public:
|
||||||
|
|
||||||
// Now for the base pool (pad) /////////////////////////////////////////////
|
// Now for the base pool (pad) /////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Enabling or disabling support creation
|
||||||
ConfigOptionBool pad_enable;
|
ConfigOptionBool pad_enable;
|
||||||
|
|
||||||
|
// The thickness of the pad walls
|
||||||
ConfigOptionFloat pad_wall_thickness /*= 2*/;
|
ConfigOptionFloat pad_wall_thickness /*= 2*/;
|
||||||
|
|
||||||
|
// The height of the pad from the bottom to the top not considering the pit
|
||||||
ConfigOptionFloat pad_wall_height /*= 5*/;
|
ConfigOptionFloat pad_wall_height /*= 5*/;
|
||||||
|
|
||||||
|
// The greatest distance where two individual pads are merged into one. The
|
||||||
|
// distance is measured roughly from the centroids of the pads.
|
||||||
ConfigOptionFloat pad_max_merge_distance /*= 50*/;
|
ConfigOptionFloat pad_max_merge_distance /*= 50*/;
|
||||||
|
|
||||||
|
// The smoothing radius of the pad edges
|
||||||
ConfigOptionFloat pad_edge_radius /*= 1*/;
|
ConfigOptionFloat pad_edge_radius /*= 1*/;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initialize(StaticCacheBase &cache, const char *base_ptr)
|
void initialize(StaticCacheBase &cache, const char *base_ptr)
|
||||||
{
|
{
|
||||||
OPT_PTR(layer_height);
|
OPT_PTR(layer_height);
|
||||||
|
OPT_PTR(supports_enable);
|
||||||
OPT_PTR(support_head_front_radius);
|
OPT_PTR(support_head_front_radius);
|
||||||
OPT_PTR(support_head_penetration);
|
OPT_PTR(support_head_penetration);
|
||||||
OPT_PTR(support_head_back_radius);
|
OPT_PTR(support_head_back_radius);
|
||||||
|
|
|
@ -1619,6 +1619,11 @@ bool SLASupportTree::generate(const PointSet &points,
|
||||||
return pc == ABORT;
|
return pc == ABORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SLASupportTree::SLASupportTree(): m_impl(new Impl())
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
const TriangleMesh &SLASupportTree::merged_mesh() const
|
const TriangleMesh &SLASupportTree::merged_mesh() const
|
||||||
{
|
{
|
||||||
return get().merged_mesh();
|
return get().merged_mesh();
|
||||||
|
|
|
@ -132,6 +132,8 @@ class SLASupportTree {
|
||||||
const Controller& ctl = {});
|
const Controller& ctl = {});
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
SLASupportTree();
|
||||||
|
|
||||||
SLASupportTree(const PointSet& pts,
|
SLASupportTree(const PointSet& pts,
|
||||||
const EigenMesh3D& em,
|
const EigenMesh3D& em,
|
||||||
const SupportConfig& cfg = {},
|
const SupportConfig& cfg = {},
|
||||||
|
@ -161,11 +163,6 @@ public:
|
||||||
/// Get the pad geometry
|
/// Get the pad geometry
|
||||||
const TriangleMesh& get_pad() const;
|
const TriangleMesh& get_pad() const;
|
||||||
|
|
||||||
/// The Z offset to raise the model and the supports to the ground level.
|
|
||||||
/// This is the elevation given in the support config and the height of the
|
|
||||||
/// pad (if requested).
|
|
||||||
double get_elevation() const;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,8 +381,11 @@ void SLAPrint::process()
|
||||||
auto ilh = float(ilhd);
|
auto ilh = float(ilhd);
|
||||||
const size_t objcount = m_objects.size();
|
const size_t objcount = m_objects.size();
|
||||||
|
|
||||||
const unsigned min_objstatus = 0;
|
const unsigned min_objstatus = 0; // where the per object operations start
|
||||||
const unsigned max_objstatus = 80;
|
const unsigned max_objstatus = 80; // where the per object operations end
|
||||||
|
|
||||||
|
// the coefficient that multiplies the per object status values which
|
||||||
|
// are set up for <0, 100>. They need to be scaled into the whole process
|
||||||
const double ostepd = (max_objstatus - min_objstatus) / (objcount * 100.0);
|
const double ostepd = (max_objstatus - min_objstatus) / (objcount * 100.0);
|
||||||
|
|
||||||
// The slicing will be performed on an imaginary 1D grid which starts from
|
// The slicing will be performed on an imaginary 1D grid which starts from
|
||||||
|
@ -410,6 +413,7 @@ void SLAPrint::process()
|
||||||
auto flh = float(lh);
|
auto flh = float(lh);
|
||||||
auto gnd = float(bb3d.min(Z));
|
auto gnd = float(bb3d.min(Z));
|
||||||
|
|
||||||
|
// The 1D grid heights
|
||||||
std::vector<float> heights;
|
std::vector<float> heights;
|
||||||
|
|
||||||
// The first layer (the one before the initial height) is added only
|
// The first layer (the one before the initial height) is added only
|
||||||
|
@ -423,26 +427,29 @@ void SLAPrint::process()
|
||||||
slicer.slice(heights, &layers, [this](){ throw_if_canceled(); });
|
slicer.slice(heights, &layers, [this](){ throw_if_canceled(); });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// this procedure simply converts the points and copies them into
|
||||||
|
// the support data cache
|
||||||
auto support_points = [](SLAPrintObject& po) {
|
auto support_points = [](SLAPrintObject& po) {
|
||||||
ModelObject& mo = *po.m_model_object;
|
ModelObject& mo = *po.m_model_object;
|
||||||
if(!mo.sla_support_points.empty()) {
|
|
||||||
po.m_supportdata.reset(new SLAPrintObject::SupportData());
|
po.m_supportdata.reset(new SLAPrintObject::SupportData());
|
||||||
po.m_supportdata->emesh = sla::to_eigenmesh(po.transformed_mesh());
|
|
||||||
|
|
||||||
|
if(!mo.sla_support_points.empty()) {
|
||||||
|
po.m_supportdata->emesh = sla::to_eigenmesh(po.transformed_mesh());
|
||||||
po.m_supportdata->support_points =
|
po.m_supportdata->support_points =
|
||||||
sla::to_point_set(po.transformed_support_points());
|
sla::to_point_set(po.transformed_support_points());
|
||||||
}
|
}
|
||||||
|
|
||||||
// for(SLAPrintObject *po : pobjects) {
|
|
||||||
// TODO: calculate automatic support points
|
|
||||||
// po->m_supportdata->slice_cache contains the slices at this point
|
|
||||||
//}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// In this step we create the supports
|
// In this step we create the supports
|
||||||
auto support_tree = [this, objcount, ostepd](SLAPrintObject& po) {
|
auto support_tree = [this, objcount, ostepd](SLAPrintObject& po) {
|
||||||
if(!po.m_supportdata) return;
|
if(!po.m_supportdata) return;
|
||||||
|
|
||||||
|
if(!po.m_config.supports_enable.getBool()) {
|
||||||
|
// Generate empty support tree. It can still host a pad
|
||||||
|
po.m_supportdata->support_tree_ptr.reset(new SLASupportTree());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto& emesh = po.m_supportdata->emesh;
|
auto& emesh = po.m_supportdata->emesh;
|
||||||
auto& pts = po.m_supportdata->support_points; // nowhere filled yet
|
auto& pts = po.m_supportdata->support_points; // nowhere filled yet
|
||||||
try {
|
try {
|
||||||
|
@ -460,10 +467,15 @@ void SLAPrint::process()
|
||||||
|
|
||||||
sla::Controller ctl;
|
sla::Controller ctl;
|
||||||
|
|
||||||
|
// some magic to scale the status values coming from the support
|
||||||
|
// tree creation into the whole print process
|
||||||
auto stfirst = OBJ_STEP_LEVELS.begin();
|
auto stfirst = OBJ_STEP_LEVELS.begin();
|
||||||
auto stthis = stfirst + slaposSupportTree;
|
auto stthis = stfirst + slaposSupportTree;
|
||||||
|
// we need to add up the status portions until this operation
|
||||||
unsigned init = std::accumulate(stfirst, stthis, 0);
|
unsigned init = std::accumulate(stfirst, stthis, 0);
|
||||||
init = unsigned(init * ostepd);
|
init = unsigned(init * ostepd); // scale the init portion
|
||||||
|
|
||||||
|
// scaling for the sub operations
|
||||||
double d = *stthis / (objcount * 100.0);
|
double d = *stthis / (objcount * 100.0);
|
||||||
|
|
||||||
ctl.statuscb = [this, init, d](unsigned st, const std::string& msg){
|
ctl.statuscb = [this, init, d](unsigned st, const std::string& msg){
|
||||||
|
@ -487,8 +499,7 @@ void SLAPrint::process()
|
||||||
// and before the supports had been sliced. (or the slicing has to be
|
// and before the supports had been sliced. (or the slicing has to be
|
||||||
// repeated)
|
// repeated)
|
||||||
|
|
||||||
if(/*po.is_step_done(slaposSupportTree) &&*/
|
if(po.m_config.pad_enable.getBool() &&
|
||||||
po.m_config.pad_enable.getBool() &&
|
|
||||||
po.m_supportdata &&
|
po.m_supportdata &&
|
||||||
po.m_supportdata->support_tree_ptr)
|
po.m_supportdata->support_tree_ptr)
|
||||||
{
|
{
|
||||||
|
@ -498,13 +509,22 @@ void SLAPrint::process()
|
||||||
double er = po.m_config.pad_edge_radius.getFloat();
|
double er = po.m_config.pad_edge_radius.getFloat();
|
||||||
double lh = po.m_config.layer_height.getFloat();
|
double lh = po.m_config.layer_height.getFloat();
|
||||||
double elevation = po.m_config.support_object_elevation.getFloat();
|
double elevation = po.m_config.support_object_elevation.getFloat();
|
||||||
|
if(!po.m_config.supports_enable.getBool()) elevation = 0;
|
||||||
sla::PoolConfig pcfg(wt, h, md, er);
|
sla::PoolConfig pcfg(wt, h, md, er);
|
||||||
|
|
||||||
sla::ExPolygons bp;
|
sla::ExPolygons bp;
|
||||||
double pad_h = sla::get_pad_elevation(pcfg);
|
double pad_h = sla::get_pad_elevation(pcfg);
|
||||||
if(elevation < pad_h) sla::base_plate(po.transformed_mesh(), bp,
|
auto&& trmesh = po.transformed_mesh();
|
||||||
|
|
||||||
|
// This call can get pretty time consuming
|
||||||
|
if(elevation < pad_h) sla::base_plate(trmesh, bp,
|
||||||
float(pad_h), float(lh));
|
float(pad_h), float(lh));
|
||||||
|
|
||||||
|
std::cout << "Mesh is empty: " << trmesh.empty() << std::endl;
|
||||||
|
std::cout << "Pad height: " << pad_h << std::endl;
|
||||||
|
std::cout << "Elevation " << elevation << std::endl;
|
||||||
|
std::cout << "Pad plate vertices: " << bp.size() << std::endl;
|
||||||
|
|
||||||
po.m_supportdata->support_tree_ptr->add_pad(bp, wt, h, md, er);
|
po.m_supportdata->support_tree_ptr->add_pad(bp, wt, h, md, er);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -914,7 +934,8 @@ bool SLAPrintObject::invalidate_all_steps()
|
||||||
}
|
}
|
||||||
|
|
||||||
double SLAPrintObject::get_elevation() const {
|
double SLAPrintObject::get_elevation() const {
|
||||||
double ret = m_config.support_object_elevation.getFloat();
|
bool se = m_config.supports_enable.getBool();
|
||||||
|
double ret = se? m_config.support_object_elevation.getFloat() : 0;
|
||||||
|
|
||||||
// if the pad is enabled, then half of the pad height is its base plate
|
// if the pad is enabled, then half of the pad height is its base plate
|
||||||
if(m_config.pad_enable.getBool()) {
|
if(m_config.pad_enable.getBool()) {
|
||||||
|
@ -935,11 +956,12 @@ double SLAPrintObject::get_elevation() const {
|
||||||
|
|
||||||
double SLAPrintObject::get_current_elevation() const
|
double SLAPrintObject::get_current_elevation() const
|
||||||
{
|
{
|
||||||
|
bool se = m_config.supports_enable.getBool();
|
||||||
bool has_supports = is_step_done(slaposSupportTree);
|
bool has_supports = is_step_done(slaposSupportTree);
|
||||||
bool has_pad = is_step_done(slaposBasePool);
|
bool has_pad = is_step_done(slaposBasePool);
|
||||||
if(!has_supports && !has_pad) return 0;
|
if(!has_supports && !has_pad) return 0;
|
||||||
else if(has_supports && !has_pad)
|
else if(has_supports && !has_pad)
|
||||||
return m_config.support_object_elevation.getFloat();
|
return se ? m_config.support_object_elevation.getFloat() : 0;
|
||||||
else return get_elevation();
|
else return get_elevation();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -402,6 +402,7 @@ const std::vector<std::string>& Preset::sla_print_options()
|
||||||
if (s_opts.empty()) {
|
if (s_opts.empty()) {
|
||||||
s_opts = {
|
s_opts = {
|
||||||
"layer_height",
|
"layer_height",
|
||||||
|
"supports_enable",
|
||||||
"support_head_front_radius",
|
"support_head_front_radius",
|
||||||
"support_head_penetration",
|
"support_head_penetration",
|
||||||
"support_head_back_radius",
|
"support_head_back_radius",
|
||||||
|
|
|
@ -2997,6 +2997,9 @@ void TabSLAPrint::build()
|
||||||
optgroup->append_single_option_line("layer_height");
|
optgroup->append_single_option_line("layer_height");
|
||||||
|
|
||||||
page = add_options_page(_(L("Supports")), "building.png");
|
page = add_options_page(_(L("Supports")), "building.png");
|
||||||
|
optgroup = page->new_optgroup(_(L("Supports")));
|
||||||
|
optgroup->append_single_option_line("supports_enable");
|
||||||
|
|
||||||
optgroup = page->new_optgroup(_(L("Support head")));
|
optgroup = page->new_optgroup(_(L("Support head")));
|
||||||
optgroup->append_single_option_line("support_head_front_radius");
|
optgroup->append_single_option_line("support_head_front_radius");
|
||||||
optgroup->append_single_option_line("support_head_back_radius");
|
optgroup->append_single_option_line("support_head_back_radius");
|
||||||
|
|
Loading…
Reference in a new issue