Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate extrusion width %s as a function of nozzle width, not layer height #1578

Merged
merged 10 commits into from
Jul 27, 2023

Conversation

iFallUpHill
Copy link

@iFallUpHill iFallUpHill commented Jul 22, 2023

image

Reviewable!

@jeremytodd1
Copy link

Yes yes yes. This is a huge one.

I believe that this single feature will get quite a few people still using SuperSlicer to switch to Orca.

Thanks for working on this! I'm very excited that this may be close to release.

@SoftFever
Copy link
Owner

@iFallUpHill
Cheers, thanks for taking on this task :)
I found a few places seems not handled properly yet in my initial review.
e.g. in gcode.cpp:1788

           float outer_wall_line_width = print.default_region_config().outer_wall_line_width.value;
            if (outer_wall_line_width == 0.0) {
                float default_line_width = print.default_object_config().line_width.value;
                outer_wall_line_width = default_line_width == 0.0 ? m_config.nozzle_diameter.get_at(initial_non_support_extruder_id) : default_line_width;
            }
            Flow outer_wall_flow = Flow(outer_wall_line_width, m_config.layer_height, m_config.nozzle_diameter.get_at(initial_non_support_extruder_id));
            float outer_wall_speed = print.default_region_config().outer_wall_speed.value;

and in src\libslic3r\MultiMaterialSegmentation.cpp:1548

    auto layer_color_stat = [&layers = std::as_const(layers)](const size_t layer_idx, const size_t color_idx) -> LayerColorStat {
        LayerColorStat out;
        const Layer &layer = *layers[layer_idx];
        for (const LayerRegion *region : layer.regions())
            if (const PrintRegionConfig &config = region->region().config();
                // color_idx == 0 means "don't know" extruder aka the underlying extruder.
                // As this region may split existing regions, we collect statistics over all regions for color_idx == 0.
                color_idx == 0 || config.wall_filament == int(color_idx)) {
                //BBS: the extrusion line width is outer wall rather than inner wall
                out.extrusion_width     = std::max<float>(out.extrusion_width, float(config.outer_wall_line_width));
                out.top_shell_layers    = std::max<int>(out.top_shell_layers, config.top_shell_layers);
                out.bottom_shell_layers = std::max<int>(out.bottom_shell_layers, config.bottom_shell_layers);
                out.small_region_threshold = config.gap_infill_speed.value > 0 ?
                                             // Gap fill enabled. Enable a single line of 1/2 extrusion width.
                                             0.5f * float(config.outer_wall_line_width) :
                                             // Gap fill disabled. Enable two lines slightly overlapping.
                                             float(config.outer_wall_line_width) + 0.7f * Flow::rounded_rectangle_extrusion_spacing(float(config.outer_wall_line_width), float(layer.height));
                out.small_region_threshold = scaled<float>(out.small_region_threshold * 0.5f);
                out.extrusion_spacing = Flow::rounded_rectangle_extrusion_spacing(float(config.outer_wall_line_width), float(layer.height));
                ++ out.num_regions;
            }
        assert(out.num_regions > 0);
        out.extrusion_width = scaled<float>(out.extrusion_width);
        out.extrusion_spacing = scaled<float>(out.extrusion_spacing);
        return out;
    };

There should be more places to handle percents, you can search for the exact name of all these changed parameters through the whole code base to find them.

@jeremytodd1 jeremytodd1 mentioned this pull request Jul 23, 2023
@iFallUpHill
Copy link
Author

iFallUpHill commented Jul 23, 2023

@SoftFever Right, I think I got them except for this one:

Does this block actually do anything? I couldn't find outer_wall_volumetric_speed being used anywhere.

Gcode.cpp

//BBS: calculate the volumetric speed of outer wall. Ignore pre-object setting and multi-filament, and just use the default setting
        {
            float filament_max_volumetric_speed = m_config.option<ConfigOptionFloats>("filament_max_volumetric_speed")->get_at(initial_non_support_extruder_id);
            float outer_wall_line_width = print.default_region_config().outer_wall_line_width.value;
            if (outer_wall_line_width == 0.0) {
                float default_line_width = print.default_object_config().line_width.value;
                outer_wall_line_width = default_line_width == 0.0 ? m_config.nozzle_diameter.get_at(initial_non_support_extruder_id) : default_line_width;
            }
            Flow outer_wall_flow = Flow(outer_wall_line_width, m_config.layer_height, m_config.nozzle_diameter.get_at(initial_non_support_extruder_id));
            float outer_wall_speed = print.default_region_config().outer_wall_speed.value;
            outer_wall_volumetric_speed = outer_wall_speed * outer_wall_flow.mm3_per_mm();
            if (outer_wall_volumetric_speed > filament_max_volumetric_speed)
                outer_wall_volumetric_speed = filament_max_volumetric_speed;
            m_placeholder_parser.set("outer_wall_volumetric_speed", new ConfigOptionFloat(outer_wall_volumetric_speed));
        }

Edit: Also pretty sure the supports don't calculate correctly anymore :'(

@iFallUpHill iFallUpHill force-pushed the extrusion_width_nozzle_percent branch from 7347e72 to 18cb687 Compare July 23, 2023 07:56
@iFallUpHill
Copy link
Author

iFallUpHill commented Jul 23, 2023

@SoftFever Got supports working again, there are a couple of extrusion widths that I think I need to handle still (marked with // TODO for extrusion width PR, but otherwise could you take a look now? I think I got the rest of them.

@SoftFever
Copy link
Owner

@SoftFever Got supports working again, there are a couple of extrusion widths that I think I need to handle still (marked with // TODO for extrusion width PR, but otherwise could you take a look now? I think I got the rest of them.

Sure thing.
Give 1 or 2 days to go through it.

@SoftFever
Copy link
Owner

I was previously worried about multi-extruder scenarios, but since Orca doesn't support multi-extruder yet, I think we can worry about that later.

def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0));
def->set_default_value(new ConfigOptionFloatOrPercent(0.4, false));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to set default to ConfigOptionFloatOrPercent(0, false).
Same for other parameters.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed all except for line_width

@SoftFever
Copy link
Owner

It's a placeholder. User can access this variable in their custom g-codes

@SoftFever Right, I think I got them except for this one:

Does this block actually do anything? I couldn't find outer_wall_volumetric_speed being used anywhere.

Gcode.cpp

//BBS: calculate the volumetric speed of outer wall. Ignore pre-object setting and multi-filament, and just use the default setting
        {
            float filament_max_volumetric_speed = m_config.option<ConfigOptionFloats>("filament_max_volumetric_speed")->get_at(initial_non_support_extruder_id);
            float outer_wall_line_width = print.default_region_config().outer_wall_line_width.value;
            if (outer_wall_line_width == 0.0) {
                float default_line_width = print.default_object_config().line_width.value;
                outer_wall_line_width = default_line_width == 0.0 ? m_config.nozzle_diameter.get_at(initial_non_support_extruder_id) : default_line_width;
            }
            Flow outer_wall_flow = Flow(outer_wall_line_width, m_config.layer_height, m_config.nozzle_diameter.get_at(initial_non_support_extruder_id));
            float outer_wall_speed = print.default_region_config().outer_wall_speed.value;
            outer_wall_volumetric_speed = outer_wall_speed * outer_wall_flow.mm3_per_mm();
            if (outer_wall_volumetric_speed > filament_max_volumetric_speed)
                outer_wall_volumetric_speed = filament_max_volumetric_speed;
            m_placeholder_parser.set("outer_wall_volumetric_speed", new ConfigOptionFloat(outer_wall_volumetric_speed));
        }

Edit: Also pretty sure the supports don't calculate correctly anymore :'(

@iFallUpHill
Copy link
Author

iFallUpHill commented Jul 23, 2023

Supports work and I fixed the above two comments!

image

@Dustmuffins
Copy link

Great feature! Thanks!

@SoftFever
Copy link
Owner

@iFallUpHill
Overall, looks good.
I made some minor fixes/changes to your branch,
Please review: 1e9a4e9

@iFallUpHill
Copy link
Author

Thanks for the cleanup, definitely looks a lot cleaner now -- only comment left is the one you mentioned about the _line_width check. Feel free to revise to unblock the merge! :D

Copy link
Owner

@SoftFever SoftFever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SoftFever
Copy link
Owner

SoftFever commented Jul 27, 2023

Merged.
Thank for the great work 👍

@SoftFever SoftFever merged commit be54f6b into SoftFever:main Jul 27, 2023
0 of 4 checks passed
SoftFever pushed a commit that referenced this pull request Aug 26, 2023
1. Previously if there are multiple sharp tails in a layer, some will be
 missed. To fix this, we should not skip if the current layer is already
 detected as sharp tails.
2. Do not mistakenly detect sharp horns as sharp tails by only detecting
 the overhang areas larger than half of the extrusion line width.

Github: #1578
Jira: STUDIO-2659
Change-Id: If7ba5c9ae547d3051551aa6fa34eb6214d01a46d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants