mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Fix integration of XS containers
This commit is contained in:
		
							parent
							
								
									9b582a11ff
								
							
						
					
					
						commit
						9458c7db97
					
				
					 34 changed files with 279 additions and 152 deletions
				
			
		|  | @ -4,7 +4,7 @@ use strict; | |||
| use warnings; | ||||
| 
 | ||||
| use Slic3r::XS; | ||||
| use Test::More tests => 5; | ||||
| use Test::More tests => 7; | ||||
| 
 | ||||
| my $point = Slic3r::Point->new(10, 15); | ||||
| is_deeply [ @$point ], [10, 15], 'point roundtrip'; | ||||
|  | @ -19,4 +19,10 @@ is_deeply [ @$point2 ], [30, 15], 'translate'; | |||
| ok $point->coincides_with($point->clone), 'coincides_with'; | ||||
| ok !$point->coincides_with($point2), 'coincides_with'; | ||||
| 
 | ||||
| { | ||||
|     my $point3 = Slic3r::Point->new(4300000, -9880845); | ||||
|     is $point->[0], $point->x, 'x accessor'; | ||||
|     is $point->[1], $point->y, 'y accessor'; | ||||
| } | ||||
| 
 | ||||
| __END__ | ||||
|  |  | |||
|  | @ -27,7 +27,7 @@ is_deeply [ map $_->pp, @$lines ], [ | |||
|     [ [100, 200], [100, 100] ], | ||||
| ], 'polygon lines'; | ||||
| 
 | ||||
| is_deeply $polygon->split_at_first_point->pp, $square, 'split_at_first_point'; | ||||
| is_deeply $polygon->split_at_index(2)->pp, [ @$square[2,3,0,1] ], 'split_at_index'; | ||||
| is_deeply $polygon->split_at_first_point->pp, [ @$square[0,1,2,3,0] ], 'split_at_first_point'; | ||||
| is_deeply $polygon->split_at_index(2)->pp, [ @$square[2,3,0,1,2] ], 'split_at_index'; | ||||
| 
 | ||||
| __END__ | ||||
|  |  | |||
|  | @ -28,10 +28,10 @@ is $loop->role, Slic3r::ExtrusionPath::EXTR_ROLE_FILL, 'modify role'; | |||
| 
 | ||||
| { | ||||
|     my $path = $loop->split_at_first_point; | ||||
|     is_deeply $path->polyline->pp, $square, 'split_at_first_point'; | ||||
|     is_deeply $path->polyline->pp, [ @$square[0,1,2,3,0] ], 'split_at_first_point'; | ||||
|     is $path->role, $loop->role, 'role preserved after split'; | ||||
|      | ||||
|     is_deeply $loop->split_at_index(2)->polyline->pp, [ @$square[2,3,0,1] ], 'split_at_index'; | ||||
|     is_deeply $loop->split_at_index(2)->polyline->pp, [ @$square[2,3,0,1,2] ], 'split_at_index'; | ||||
| } | ||||
| 
 | ||||
| __END__ | ||||
|  |  | |||
							
								
								
									
										40
									
								
								xs/t/10_line.t
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								xs/t/10_line.t
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,40 @@ | |||
| #!/usr/bin/perl | ||||
| 
 | ||||
| use strict; | ||||
| use warnings; | ||||
| 
 | ||||
| use Slic3r::XS; | ||||
| use Test::More tests => 6; | ||||
| 
 | ||||
| my $points = [ | ||||
|     [100, 100], | ||||
|     [200, 100], | ||||
| ]; | ||||
| 
 | ||||
| my $line = Slic3r::Line->new(@$points); | ||||
| is_deeply $line->pp, $points, 'line roundtrip'; | ||||
| 
 | ||||
| is ref($line->arrayref), 'ARRAY', 'line arrayref is unblessed'; | ||||
| isa_ok $line->[0], 'Slic3r::Point', 'line point is blessed'; | ||||
| 
 | ||||
| { | ||||
|     my $clone = $line->clone; | ||||
|     $clone->reverse; | ||||
|     is_deeply $clone->pp, [ reverse @$points ], 'reverse'; | ||||
| } | ||||
| 
 | ||||
| { | ||||
|     my $line2 = Slic3r::Line->new($line->a->clone, $line->b->clone); | ||||
|     is_deeply $line2->pp, $points, 'line roundtrip with cloned points'; | ||||
| } | ||||
| 
 | ||||
| { | ||||
|     my $clone = $line->clone; | ||||
|     $clone->translate(10, -5); | ||||
|     is_deeply $clone->pp, [ | ||||
|         [110, 95], | ||||
|         [210, 95], | ||||
|     ], 'translate'; | ||||
| } | ||||
| 
 | ||||
| __END__ | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci