mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 20:51:12 -06:00 
			
		
		
		
	Fix complete_objects after XS port. Includes regression test. #1511
This commit is contained in:
		
							parent
							
								
									f491b7ba71
								
							
						
					
					
						commit
						0b63afb370
					
				
					 3 changed files with 17 additions and 8 deletions
				
			
		|  | @ -7,7 +7,7 @@ use List::Util qw(min max first); | ||||||
| use Math::ConvexHull::MonotoneChain qw(convex_hull); | use Math::ConvexHull::MonotoneChain qw(convex_hull); | ||||||
| use Slic3r::ExtrusionPath ':roles'; | use Slic3r::ExtrusionPath ':roles'; | ||||||
| use Slic3r::Geometry qw(X Y Z X1 Y1 X2 Y2 MIN MAX PI scale unscale move_points chained_path); | use Slic3r::Geometry qw(X Y Z X1 Y1 X2 Y2 MIN MAX PI scale unscale move_points chained_path); | ||||||
| use Slic3r::Geometry::Clipper qw(diff_ex union_ex union_pt intersection_ex offset | use Slic3r::Geometry::Clipper qw(diff_ex union_ex union_pt intersection_ex intersection offset | ||||||
|     offset2 traverse_pt JT_ROUND JT_SQUARE); |     offset2 traverse_pt JT_ROUND JT_SQUARE); | ||||||
| use Time::HiRes qw(gettimeofday tv_interval); | use Time::HiRes qw(gettimeofday tv_interval); | ||||||
| 
 | 
 | ||||||
|  | @ -170,9 +170,7 @@ sub validate { | ||||||
|                 { |                 { | ||||||
|                     my @points = map [ @$_[X,Y] ], map @{$_->vertices}, @{$self->objects->[$obj_idx]->meshes}; |                     my @points = map [ @$_[X,Y] ], map @{$_->vertices}, @{$self->objects->[$obj_idx]->meshes}; | ||||||
|                     my $convex_hull = Slic3r::Polygon->new(@{convex_hull(\@points)}); |                     my $convex_hull = Slic3r::Polygon->new(@{convex_hull(\@points)}); | ||||||
|                     ($clearance) = map Slic3r::Polygon->new(@$_),  |                     ($clearance) = @{offset([$convex_hull], scale $Slic3r::Config->extruder_clearance_radius / 2, 1, JT_ROUND)}; | ||||||
|                                         @{Slic3r::Geometry::Clipper::offset( |  | ||||||
|                                             [$convex_hull], scale $Slic3r::Config->extruder_clearance_radius / 2, 1, JT_ROUND)}; |  | ||||||
|                 } |                 } | ||||||
|                 for my $copy (@{$self->objects->[$obj_idx]->copies}) { |                 for my $copy (@{$self->objects->[$obj_idx]->copies}) { | ||||||
|                     my $copy_clearance = $clearance->clone; |                     my $copy_clearance = $clearance->clone; | ||||||
|  | @ -180,7 +178,7 @@ sub validate { | ||||||
|                     if (@{ intersection(\@a, [$copy_clearance]) }) { |                     if (@{ intersection(\@a, [$copy_clearance]) }) { | ||||||
|                         die "Some objects are too close; your extruder will collide with them.\n"; |                         die "Some objects are too close; your extruder will collide with them.\n"; | ||||||
|                     } |                     } | ||||||
|                     @a = map @$_, @{union_ex([ @a, $copy_clearance ])}; |                     @a = map $_->clone, map @$_, @{union_ex([ @a, $copy_clearance ])}; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -90,7 +90,7 @@ sub model { | ||||||
|     my $object = $model->add_object; |     my $object = $model->add_object; | ||||||
|     $object->add_volume(mesh => $mesh); |     $object->add_volume(mesh => $mesh); | ||||||
|     $object->add_instance( |     $object->add_instance( | ||||||
|         offset      => [0,0], |         offset      => Slic3r::Point->new(0,0), | ||||||
|         rotation    => $params{rotation} // 0, |         rotation    => $params{rotation} // 0, | ||||||
|     ); |     ); | ||||||
|     return $model; |     return $model; | ||||||
|  | @ -106,7 +106,10 @@ sub init_print { | ||||||
|     my $print = Slic3r::Print->new(config => $config); |     my $print = Slic3r::Print->new(config => $config); | ||||||
|      |      | ||||||
|     $model_name = [$model_name] if ref($model_name) ne 'ARRAY'; |     $model_name = [$model_name] if ref($model_name) ne 'ARRAY'; | ||||||
|     $print->add_model(model($_, %params)) for @$model_name; |     for my $model (map model($_, %params), @$model_name) { | ||||||
|  |         $model->arrange_objects($config); | ||||||
|  |         $print->add_model($model); | ||||||
|  |     } | ||||||
|     $print->validate; |     $print->validate; | ||||||
|      |      | ||||||
|     return $print; |     return $print; | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								t/gcode.t
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								t/gcode.t
									
										
									
									
									
								
							|  | @ -1,4 +1,4 @@ | ||||||
| use Test::More tests => 3; | use Test::More tests => 4; | ||||||
| use strict; | use strict; | ||||||
| use warnings; | use warnings; | ||||||
| 
 | 
 | ||||||
|  | @ -42,4 +42,12 @@ use Slic3r::Test; | ||||||
|     ok !defined (first { abs($_ - $config->retract_speed->[0]*60) < 5 } @retract_speeds), 'wipe moves don\'t retract faster than configured speed'; |     ok !defined (first { abs($_ - $config->retract_speed->[0]*60) < 5 } @retract_speeds), 'wipe moves don\'t retract faster than configured speed'; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | { | ||||||
|  |     my $config = Slic3r::Config->new_from_defaults; | ||||||
|  |     $config->set('complete_objects', 1); | ||||||
|  |     $config->set('duplicate', 2); | ||||||
|  |     my $print = Slic3r::Test::init_print('20mm_cube', config => $config); | ||||||
|  |     ok Slic3r::Test::gcode($print), "complete_objects"; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| __END__ | __END__ | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci