Adding checkbox for disabling support generation (still having pad generation)
This commit is contained in:
parent
7efadfae1c
commit
d28b61f8a3
@ -8,8 +8,6 @@
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
// TODO: these classes are untested
|
||||
|
||||
/// Handy little spin mutex for the cached meshes.
|
||||
/// Implements the "Lockable" concept
|
||||
class SpinMutex {
|
||||
|
@ -2445,6 +2445,14 @@ void PrintConfigDef::init_sla_params()
|
||||
def = this->add("sla_print_settings_id", coString);
|
||||
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->label = L("Support head front radius");
|
||||
def->category = L("Supports");
|
||||
|
@ -904,6 +904,9 @@ class SLAPrintObjectConfig : public StaticPrintConfig
|
||||
public:
|
||||
ConfigOptionFloat layer_height;
|
||||
|
||||
// Enabling or disabling support creation
|
||||
ConfigOptionBool supports_enable;
|
||||
|
||||
// Radius in mm of the pointing side of the head.
|
||||
ConfigOptionFloat support_head_front_radius /*= 0.2*/;
|
||||
|
||||
@ -942,16 +945,27 @@ public:
|
||||
|
||||
// Now for the base pool (pad) /////////////////////////////////////////////
|
||||
|
||||
// Enabling or disabling support creation
|
||||
ConfigOptionBool pad_enable;
|
||||
|
||||
// The thickness of the pad walls
|
||||
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*/;
|
||||
|
||||
// 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*/;
|
||||
|
||||
// The smoothing radius of the pad edges
|
||||
ConfigOptionFloat pad_edge_radius /*= 1*/;
|
||||
|
||||
protected:
|
||||
void initialize(StaticCacheBase &cache, const char *base_ptr)
|
||||
{
|
||||
OPT_PTR(layer_height);
|
||||
OPT_PTR(supports_enable);
|
||||
OPT_PTR(support_head_front_radius);
|
||||
OPT_PTR(support_head_penetration);
|
||||
OPT_PTR(support_head_back_radius);
|
||||
|
@ -1619,6 +1619,11 @@ bool SLASupportTree::generate(const PointSet &points,
|
||||
return pc == ABORT;
|
||||
}
|
||||
|
||||
SLASupportTree::SLASupportTree(): m_impl(new Impl())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const TriangleMesh &SLASupportTree::merged_mesh() const
|
||||
{
|
||||
return get().merged_mesh();
|
||||
|
@ -132,6 +132,8 @@ class SLASupportTree {
|
||||
const Controller& ctl = {});
|
||||
public:
|
||||
|
||||
SLASupportTree();
|
||||
|
||||
SLASupportTree(const PointSet& pts,
|
||||
const EigenMesh3D& em,
|
||||
const SupportConfig& cfg = {},
|
||||
@ -161,11 +163,6 @@ public:
|
||||
/// Get the pad geometry
|
||||
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);
|
||||
const size_t objcount = m_objects.size();
|
||||
|
||||
const unsigned min_objstatus = 0;
|
||||
const unsigned max_objstatus = 80;
|
||||
const unsigned min_objstatus = 0; // where the per object operations start
|
||||
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);
|
||||
|
||||
// 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 gnd = float(bb3d.min(Z));
|
||||
|
||||
// The 1D grid heights
|
||||
std::vector<float> heights;
|
||||
|
||||
// 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(); });
|
||||
};
|
||||
|
||||
// this procedure simply converts the points and copies them into
|
||||
// the support data cache
|
||||
auto support_points = [](SLAPrintObject& po) {
|
||||
ModelObject& mo = *po.m_model_object;
|
||||
if(!mo.sla_support_points.empty()) {
|
||||
po.m_supportdata.reset(new SLAPrintObject::SupportData());
|
||||
po.m_supportdata->emesh = sla::to_eigenmesh(po.transformed_mesh());
|
||||
po.m_supportdata.reset(new SLAPrintObject::SupportData());
|
||||
|
||||
if(!mo.sla_support_points.empty()) {
|
||||
po.m_supportdata->emesh = sla::to_eigenmesh(po.transformed_mesh());
|
||||
po.m_supportdata->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
|
||||
auto support_tree = [this, objcount, ostepd](SLAPrintObject& po) {
|
||||
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& pts = po.m_supportdata->support_points; // nowhere filled yet
|
||||
try {
|
||||
@ -460,10 +467,15 @@ void SLAPrint::process()
|
||||
|
||||
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 stthis = stfirst + slaposSupportTree;
|
||||
// we need to add up the status portions until this operation
|
||||
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);
|
||||
|
||||
ctl.statuscb = [this, init, d](unsigned st, const std::string& msg){
|
||||
@ -472,7 +484,7 @@ void SLAPrint::process()
|
||||
ctl.stopcondition = [this](){ return canceled(); };
|
||||
ctl.cancelfn = [this]() { throw_if_canceled(); };
|
||||
|
||||
po.m_supportdata->support_tree_ptr.reset(
|
||||
po.m_supportdata->support_tree_ptr.reset(
|
||||
new SLASupportTree(pts, emesh, scfg, ctl));
|
||||
|
||||
} catch(sla::SLASupportsStoppedException&) {
|
||||
@ -487,8 +499,7 @@ void SLAPrint::process()
|
||||
// and before the supports had been sliced. (or the slicing has to be
|
||||
// repeated)
|
||||
|
||||
if(/*po.is_step_done(slaposSupportTree) &&*/
|
||||
po.m_config.pad_enable.getBool() &&
|
||||
if(po.m_config.pad_enable.getBool() &&
|
||||
po.m_supportdata &&
|
||||
po.m_supportdata->support_tree_ptr)
|
||||
{
|
||||
@ -498,13 +509,22 @@ void SLAPrint::process()
|
||||
double er = po.m_config.pad_edge_radius.getFloat();
|
||||
double lh = po.m_config.layer_height.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::ExPolygons bp;
|
||||
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));
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
@ -914,7 +934,8 @@ bool SLAPrintObject::invalidate_all_steps()
|
||||
}
|
||||
|
||||
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(m_config.pad_enable.getBool()) {
|
||||
@ -935,11 +956,12 @@ double SLAPrintObject::get_elevation() const {
|
||||
|
||||
double SLAPrintObject::get_current_elevation() const
|
||||
{
|
||||
bool se = m_config.supports_enable.getBool();
|
||||
bool has_supports = is_step_done(slaposSupportTree);
|
||||
bool has_pad = is_step_done(slaposBasePool);
|
||||
if(!has_supports && !has_pad) return 0;
|
||||
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();
|
||||
|
||||
return 0;
|
||||
|
@ -402,6 +402,7 @@ const std::vector<std::string>& Preset::sla_print_options()
|
||||
if (s_opts.empty()) {
|
||||
s_opts = {
|
||||
"layer_height",
|
||||
"supports_enable",
|
||||
"support_head_front_radius",
|
||||
"support_head_penetration",
|
||||
"support_head_back_radius",
|
||||
|
@ -2997,6 +2997,9 @@ void TabSLAPrint::build()
|
||||
optgroup->append_single_option_line("layer_height");
|
||||
|
||||
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->append_single_option_line("support_head_front_radius");
|
||||
optgroup->append_single_option_line("support_head_back_radius");
|
||||
|
Loading…
Reference in New Issue
Block a user