mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Fixed regression causing bridge flow to be incorrect when a manual default extrusion width was specified. Includes several regression tests. #2027
This commit is contained in:
		
							parent
							
								
									39b8ac80ee
								
							
						
					
					
						commit
						28695c719c
					
				
					 2 changed files with 42 additions and 3 deletions
				
			
		
							
								
								
									
										42
									
								
								t/flow.t
									
										
									
									
									
								
							
							
						
						
									
										42
									
								
								t/flow.t
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
use Test::More tests => 1;
 | 
			
		||||
use Test::More tests => 6;
 | 
			
		||||
use strict;
 | 
			
		||||
use warnings;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -9,7 +9,7 @@ BEGIN {
 | 
			
		|||
 | 
			
		||||
use List::Util qw(first sum);
 | 
			
		||||
use Slic3r;
 | 
			
		||||
use Slic3r::Geometry qw(scale);
 | 
			
		||||
use Slic3r::Geometry qw(scale PI);
 | 
			
		||||
use Slic3r::Test;
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -38,4 +38,42 @@ use Slic3r::Test;
 | 
			
		|||
        'first_layer_extrusion_width applies to everything on first layer';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
    my $config = Slic3r::Config->new_from_defaults;
 | 
			
		||||
    $config->set('bridge_speed', 99);
 | 
			
		||||
    $config->set('bridge_flow_ratio', 1);
 | 
			
		||||
    $config->set('cooling', 0);                 # to prevent speeds from being altered
 | 
			
		||||
    $config->set('first_layer_speed', '100%');  # to prevent speeds from being altered
 | 
			
		||||
    
 | 
			
		||||
    my $test = sub {
 | 
			
		||||
        my $print = Slic3r::Test::init_print('overhang', config => $config);
 | 
			
		||||
        my @E_per_mm = ();
 | 
			
		||||
        Slic3r::GCode::Reader->new->parse(my $gcode = Slic3r::Test::gcode($print), sub {
 | 
			
		||||
            my ($self, $cmd, $args, $info) = @_;
 | 
			
		||||
        
 | 
			
		||||
            if ($info->{extruding} && $info->{dist_XY} > 0) {
 | 
			
		||||
                if (($args->{F} // $self->F) == $config->bridge_speed*60) {
 | 
			
		||||
                    push @E_per_mm, $info->{dist_E} / $info->{dist_XY};
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        my $expected_mm3_per_mm = ($config->nozzle_diameter->[0]**2) * PI/4 * $config->bridge_flow_ratio;
 | 
			
		||||
        my $expected_E_per_mm = $expected_mm3_per_mm / ((($config->filament_diameter->[0]/2)**2)*PI);
 | 
			
		||||
        ok !(defined first { abs($_ - $expected_E_per_mm) > 0.01 } @E_per_mm),
 | 
			
		||||
            'expected flow when using bridge_flow_ratio = ' . $config->bridge_flow_ratio;
 | 
			
		||||
    };
 | 
			
		||||
    
 | 
			
		||||
    $config->set('bridge_flow_ratio', 0.5);
 | 
			
		||||
    $test->();
 | 
			
		||||
    $config->set('bridge_flow_ratio', 2);
 | 
			
		||||
    $test->();
 | 
			
		||||
    $config->set('extrusion_width', 0.4);
 | 
			
		||||
    $config->set('bridge_flow_ratio', 1);
 | 
			
		||||
    $test->();
 | 
			
		||||
    $config->set('bridge_flow_ratio', 0.5);
 | 
			
		||||
    $test->();
 | 
			
		||||
    $config->set('bridge_flow_ratio', 2);
 | 
			
		||||
    $test->();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
__END__
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,8 @@ Flow::new_from_config_width(FlowRole role, const ConfigOptionFloatOrPercent &wid
 | 
			
		|||
    if (height <= 0 && bridge_flow_ratio == 0) CONFESS("Invalid flow height supplied to new_from_config_width()");
 | 
			
		||||
    
 | 
			
		||||
    float w;
 | 
			
		||||
    if (!width.percent && width.value == 0) {
 | 
			
		||||
    // use automatic extrusion width if user left 0 or we need a bridge flow
 | 
			
		||||
    if ((!width.percent && width.value == 0) || bridge_flow_ratio > 0) {
 | 
			
		||||
        w = Flow::_width(role, nozzle_diameter, height, bridge_flow_ratio);
 | 
			
		||||
    } else {
 | 
			
		||||
        w = width.get_abs_value(height);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue