mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Return Surface->expolygon by reference
This commit is contained in:
		
							parent
							
								
									828785312e
								
							
						
					
					
						commit
						bb45437526
					
				
					 3 changed files with 14 additions and 3 deletions
				
			
		|  | @ -22,6 +22,11 @@ use overload | |||
|     '@{}' => sub { $_[0]->arrayref }, | ||||
|     'fallback' => 1; | ||||
| 
 | ||||
| package Slic3r::ExPolygon::Ref; | ||||
| our @ISA = 'Slic3r::ExPolygon'; | ||||
| 
 | ||||
| sub DESTROY {} | ||||
| 
 | ||||
| package Slic3r::Polyline; | ||||
| use overload | ||||
|     '@{}' => sub { $_[0]->arrayref }, | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ use strict; | |||
| use warnings; | ||||
| 
 | ||||
| use Slic3r::XS; | ||||
| use Test::More tests => 12; | ||||
| use Test::More tests => 13; | ||||
| 
 | ||||
| my $square = [  # ccw | ||||
|     [100, 100], | ||||
|  | @ -27,7 +27,7 @@ my $surface = Slic3r::Surface->new( | |||
| 
 | ||||
| $surface = $surface->clone; | ||||
| 
 | ||||
| isa_ok $surface->expolygon, 'Slic3r::ExPolygon', 'expolygon'; | ||||
| isa_ok $surface->expolygon, 'Slic3r::ExPolygon::Ref', 'expolygon'; | ||||
| is_deeply [ @{$surface->expolygon->pp} ], [$square, $hole_in_square], 'expolygon roundtrip'; | ||||
| is scalar(@{$surface->polygons}), 2, 'polygons roundtrip'; | ||||
| 
 | ||||
|  | @ -41,6 +41,12 @@ is $surface->bridge_angle, 30, 'bridge_angle'; | |||
| $surface->extra_perimeters(2); | ||||
| is $surface->extra_perimeters, 2, 'extra_perimeters'; | ||||
| 
 | ||||
| { | ||||
|     my $surface2 = $surface->clone; | ||||
|     $surface2->expolygon->scale(2); | ||||
|     isnt $surface2->expolygon->area, $expolygon->area, 'expolygon is returned by reference'; | ||||
| } | ||||
| 
 | ||||
| { | ||||
|     my $collection = Slic3r::Surface::Collection->new($surface, $surface->clone); | ||||
|     is scalar(@$collection), 2, 'collection has the right number of items'; | ||||
|  |  | |||
|  | @ -8,7 +8,7 @@ | |||
| %name{Slic3r::Surface} class Surface { | ||||
|     ~Surface(); | ||||
|     ExPolygon* expolygon() | ||||
|         %code{% const char* CLASS = "Slic3r::ExPolygon"; RETVAL = new ExPolygon(THIS->expolygon); %}; | ||||
|         %code{% const char* CLASS = "Slic3r::ExPolygon::Ref"; RETVAL = &(THIS->expolygon); %}; | ||||
|     double thickness() | ||||
|         %code{% RETVAL = THIS->thickness; %}; | ||||
|     unsigned short thickness_layers() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci