mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Rewritten half-edge traversal in a more robust way. Includes first medial axis unit test
This commit is contained in:
		
							parent
							
								
									eadffe4a9e
								
							
						
					
					
						commit
						b49a652736
					
				
					 4 changed files with 82 additions and 71 deletions
				
			
		
							
								
								
									
										25
									
								
								t/thin.t
									
										
									
									
									
								
							
							
						
						
									
										25
									
								
								t/thin.t
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
use Test::More tests => 1;
 | 
			
		||||
use Test::More tests => 3;
 | 
			
		||||
use strict;
 | 
			
		||||
use warnings;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -9,7 +9,7 @@ BEGIN {
 | 
			
		|||
 | 
			
		||||
use Slic3r;
 | 
			
		||||
use List::Util qw(first);
 | 
			
		||||
use Slic3r::Geometry qw(epsilon);
 | 
			
		||||
use Slic3r::Geometry qw(epsilon scale);
 | 
			
		||||
use Slic3r::Test;
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -45,4 +45,25 @@ use Slic3r::Test;
 | 
			
		|||
        'no superfluous thin walls are generated for toothed profile';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
my $square = Slic3r::Polygon->new_scale(  # ccw
 | 
			
		||||
    [100, 100],
 | 
			
		||||
    [200, 100],
 | 
			
		||||
    [200, 200],
 | 
			
		||||
    [100, 200],
 | 
			
		||||
);
 | 
			
		||||
my $hole_in_square = Slic3r::Polygon->new_scale(  # cw
 | 
			
		||||
    [140, 140],
 | 
			
		||||
    [140, 160],
 | 
			
		||||
    [160, 160],
 | 
			
		||||
    [160, 140],
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
    my $expolygon = Slic3r::ExPolygon->new($square, $hole_in_square);
 | 
			
		||||
    my $res = $expolygon->medial_axis(scale 10);
 | 
			
		||||
    is scalar(@$res), 1, 'medial axis of a square shape is a single closed loop';
 | 
			
		||||
    ok $res->[0]->length > $hole_in_square->length && $res->[0]->length < $square->length,
 | 
			
		||||
        'medial axis loop has reasonable length';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
__END__
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue