mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Added first unit test for bridge direction
This commit is contained in:
		
							parent
							
								
									119778caa9
								
							
						
					
					
						commit
						23e6abff49
					
				
					 2 changed files with 36 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -1,8 +1,9 @@
 | 
			
		|||
package Slic3r::Layer::BridgeDetector;
 | 
			
		||||
use Moo;
 | 
			
		||||
 | 
			
		||||
use List::Util qw(first sum);
 | 
			
		||||
use Slic3r::Geometry qw(PI);
 | 
			
		||||
use Slic3r::Geometry::Clipper qw(intersection_pl);
 | 
			
		||||
use Slic3r::Geometry::Clipper qw(intersection_pl intersection_ex);
 | 
			
		||||
 | 
			
		||||
has 'lower_slices'      => (is => 'ro', required => 1);  # ExPolygons or ExPolygonCollection
 | 
			
		||||
has 'perimeter_flow'    => (is => 'ro', required => 1);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										34
									
								
								t/bridges.t
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								t/bridges.t
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,34 @@
 | 
			
		|||
use Test::More tests => 1;
 | 
			
		||||
use strict;
 | 
			
		||||
use warnings;
 | 
			
		||||
 | 
			
		||||
BEGIN {
 | 
			
		||||
    use FindBin;
 | 
			
		||||
    use lib "$FindBin::Bin/../lib";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
use List::Util qw(first);
 | 
			
		||||
use Slic3r;
 | 
			
		||||
use Slic3r::Geometry qw(scale);
 | 
			
		||||
use Slic3r::Test;
 | 
			
		||||
 | 
			
		||||
my $flow = Slic3r::Flow->new(width => 0.5, spacing => 0.45, nozzle_diameter => 0.5);
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
    my $lower = Slic3r::ExPolygon->new(
 | 
			
		||||
        Slic3r::Polygon->new_scale([0,0], [20,0], [20,10], [0,10]),
 | 
			
		||||
        Slic3r::Polygon->new_scale([2,2], [2,8], [18,8], [18,2]),
 | 
			
		||||
    );
 | 
			
		||||
    my $bridge = $lower->[1]->clone;
 | 
			
		||||
    $bridge->reverse;
 | 
			
		||||
    $bridge = Slic3r::ExPolygon->new($bridge);
 | 
			
		||||
    my $bd = Slic3r::Layer::BridgeDetector->new(
 | 
			
		||||
        lower_slices    => [$lower],
 | 
			
		||||
        perimeter_flow  => $flow,
 | 
			
		||||
        infill_flow     => $flow,
 | 
			
		||||
    );
 | 
			
		||||
    # 0 is North/South
 | 
			
		||||
    is $bd->detect_angle($bridge), 0, 'correct bridge angle detected';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
__END__
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue