diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index e71671021..3e1ee9f9f 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2566,6 +2566,14 @@ void PrintConfigDef::init_sla_params() def->enum_labels.push_back(L("Dynamic")); def->default_value = new ConfigOptionEnum(slapcmDynamic); + def = this->add("support_buildplate_only", coBool); + def->label = L("Support on build plate only"); + def->category = L("Supports"); + def->tooltip = L("Only create support if it lies on a build plate. Don't create support on a print."); + def->cli = "support-buildplate-only!"; + def->mode = comSimple; + def->default_value = new ConfigOptionBool(false); + def = this->add("support_pillar_widening_factor", coFloat); def->label = L("Pillar widening factor"); def->category = L("Supports"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 6b9e68eef..20c089d1c 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -976,6 +976,9 @@ public: // How the pillars are bridged together ConfigOptionEnum support_pillar_connection_mode; + // Generate only ground facing supports + ConfigOptionBool support_buildplate_only; + // 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 @@ -1031,6 +1034,7 @@ protected: OPT_PTR(support_head_width); OPT_PTR(support_pillar_diameter); OPT_PTR(support_pillar_connection_mode); + OPT_PTR(support_buildplate_only); OPT_PTR(support_pillar_widening_factor); OPT_PTR(support_base_diameter); OPT_PTR(support_base_height); diff --git a/src/libslic3r/SLA/SLABasePool.cpp b/src/libslic3r/SLA/SLABasePool.cpp index f1e79357d..a235d52ba 100644 --- a/src/libslic3r/SLA/SLABasePool.cpp +++ b/src/libslic3r/SLA/SLABasePool.cpp @@ -427,6 +427,7 @@ ExPolygons concave_hull(const ExPolygons& polys, double max_dist_mm = 50, return r; }); + // This is unavoidable... punion = unify(punion); return punion; @@ -448,10 +449,17 @@ void base_plate(const TriangleMesh &mesh, ExPolygons &output, float h, slicer.slice(heights, &out, thrfn); size_t count = 0; for(auto& o : out) count += o.size(); + + // Now we have to unify all slice layers which can be an expensive operation + // so we will try to simplify the polygons ExPolygons tmp; tmp.reserve(count); - for(auto& o : out) for(auto& e : o) tmp.emplace_back(std::move(e)); + for(ExPolygons& o : out) for(ExPolygon& e : o) { + auto&& exss = e.simplify(0.1/SCALING_FACTOR); + for(ExPolygon& ep : exss) tmp.emplace_back(std::move(ep)); + } ExPolygons utmp = unify(tmp); + for(auto& o : utmp) { auto&& smp = o.simplify(0.1/SCALING_FACTOR); output.insert(output.end(), smp.begin(), smp.end()); diff --git a/src/libslic3r/SLA/SLASupportTree.cpp b/src/libslic3r/SLA/SLASupportTree.cpp index 54e3a0189..5a5187093 100644 --- a/src/libslic3r/SLA/SLASupportTree.cpp +++ b/src/libslic3r/SLA/SLASupportTree.cpp @@ -1898,6 +1898,17 @@ bool SLASupportTree::generate(const PointSet &points, } }; + if(cfg.ground_facing_only) { // Delete the non-gnd steps if necessary + program[ROUTING_NONGROUND] = []() { + BOOST_LOG_TRIVIAL(info) << "Skipping non-ground facing supports as " + "requested."; + }; + program[HEADLESS] = [](){ + BOOST_LOG_TRIVIAL(info) << "Skipping headless stick generation as " + "requested"; + }; + } + Steps pc = BEGIN, pc_prev = BEGIN; // Let's define a simple automaton that will run our program. diff --git a/src/libslic3r/SLA/SLASupportTree.hpp b/src/libslic3r/SLA/SLASupportTree.hpp index 8de8d2b33..7d23a981f 100644 --- a/src/libslic3r/SLA/SLASupportTree.hpp +++ b/src/libslic3r/SLA/SLASupportTree.hpp @@ -55,6 +55,9 @@ struct SupportConfig { // How to connect pillars PillarConnectionMode pillar_connection_mode = PillarConnectionMode::dynamic; + // Only generate pillars that can be routed to ground + bool ground_facing_only = false; + // 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 diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 3cc689558..142428f1d 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -363,7 +363,11 @@ SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, const DynamicPrintConf const_cast(*it_print_object_status).status = PrintObjectStatus::Reused; } else { auto print_object = new SLAPrintObject(this, &model_object); + + // FIXME: this invalidates the transformed mesh in SLAPrintObject + // which is expensive to calculate (especially the raw_mesh() call) print_object->set_trafo(sla_trafo(model_object)); + print_object->set_instances(new_instances); print_object->config_apply(config, true); print_objects_new.emplace_back(print_object); @@ -415,6 +419,7 @@ sla::SupportConfig make_support_cfg(const SLAPrintObjectConfig& c) { case slapcmDynamic: scfg.pillar_connection_mode = sla::PillarConnectionMode::dynamic; break; } + scfg.ground_facing_only = c.support_buildplate_only.getBool(); scfg.pillar_widening_factor = c.support_pillar_widening_factor.getFloat(); scfg.base_radius_mm = 0.5*c.support_base_diameter.getFloat(); scfg.base_height_mm = c.support_base_height.getFloat(); @@ -620,8 +625,8 @@ void SLAPrint::process() // repeated) if(!po.m_supportdata || !po.m_supportdata->support_tree_ptr) { - BOOST_LOG_TRIVIAL(warning) << "Uninitialized support data at " - << "pad creation."; + BOOST_LOG_TRIVIAL(error) << "Uninitialized support data at " + << "pad creation."; return; } @@ -643,9 +648,11 @@ void SLAPrint::process() // This call can get pretty time consuming auto thrfn = [this](){ throw_if_canceled(); }; - if(elevation < pad_h) + if(elevation < pad_h) { + // we have to count with the model geometry for the base plate sla::base_plate(trmesh, bp, float(pad_h), float(lh), thrfn); + } pcfg.throw_on_cancel = thrfn; po.m_supportdata->support_tree_ptr->add_pad(bp, pcfg); @@ -939,7 +946,7 @@ void SLAPrint::process() }; // this would disable the rasterization step -// m_stepmask[slapsRasterize] = false; + // m_stepmask[slapsRasterize] = false; double pstd = (100 - max_objstatus) / 100.0; st = max_objstatus; @@ -1063,6 +1070,7 @@ bool SLAPrintObject::invalidate_state_by_config_options(const std::vectorCallAfter([gui, &input_files, &cli_config, &extra_config, &print_config] { + if (! gui->initialized()) { + return; + } #if 0 // Load the cummulative config over the currently active profiles. //FIXME if multiple configs are loaded, only the last one will have an effect. diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 84a2b61cf..f043deda5 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -600,7 +600,8 @@ void GLCanvas3D::Bed::_render_prusa(const std::string &key, float theta) const #if ENABLE_ANISOTROPIC_FILTER_ON_BED_TEXTURES GLfloat max_anisotropy = 0.0f; - ::glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropy); + if (glewIsSupported("GL_EXT_texture_filter_anisotropic")) + ::glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropy); #endif // ENABLE_ANISOTROPIC_FILTER_ON_BED_TEXTURES std::string filename = tex_path + "_top.png"; diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 056062cf4..fe96aaa80 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -197,7 +197,7 @@ bool GUI_App::OnInit() mainframe->Show(true); - return true; + return m_initialized = true; } unsigned GUI_App::get_colour_approx_luma(const wxColour &colour) diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 79da4531d..43938b66a 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -71,6 +71,7 @@ static wxString dots("…", wxConvUTF8); class GUI_App : public wxApp { + bool m_initialized { false }; bool app_conf_exists{ false }; wxColour m_color_label_modified; @@ -90,6 +91,7 @@ class GUI_App : public wxApp public: bool OnInit() override; + bool initialized() const { return m_initialized; } GUI_App(); diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index 871cd0b73..ee182a01a 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -414,6 +414,7 @@ const std::vector& Preset::sla_print_options() "support_head_width", "support_pillar_diameter", "support_pillar_connection_mode", + "support_buildplate_only", "support_pillar_widening_factor", "support_base_diameter", "support_base_height", diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 69b3c5b30..28b7cd248 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3191,6 +3191,7 @@ void TabSLAPrint::build() optgroup = page->new_optgroup(_(L("Support pillar"))); optgroup->append_single_option_line("support_pillar_diameter"); optgroup->append_single_option_line("support_pillar_connection_mode"); + optgroup->append_single_option_line("support_buildplate_only"); optgroup->append_single_option_line("support_pillar_widening_factor"); optgroup->append_single_option_line("support_base_diameter"); optgroup->append_single_option_line("support_base_height");