mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 20:51:12 -06:00 
			
		
		
		
	Fix positioning and other things
This commit is contained in:
		
							parent
							
								
									d488afd243
								
							
						
					
					
						commit
						e2ab340edb
					
				
					 3 changed files with 24 additions and 14 deletions
				
			
		|  | @ -409,7 +409,7 @@ sub process_bridges { | |||
|                 my @chords = map Slic3r::Line->new($_->[0], $_->[-1]), @edges; | ||||
|                 my @midpoints = map $_->midpoint, @chords; | ||||
|                 my $line_between_midpoints = Slic3r::Line->new(@midpoints); | ||||
|                 $bridge_angle = rad2deg_dir($line_between_midpoints->direction); | ||||
|                 $bridge_angle = Slic3r::Geometry::rad2deg_dir($line_between_midpoints->direction); | ||||
|             } elsif (@edges == 1) { | ||||
|                 # TODO: this case includes both U-shaped bridges and plain overhangs; | ||||
|                 # we need a trapezoidation algorithm to detect the actual bridged area | ||||
|  | @ -418,10 +418,10 @@ sub process_bridges { | |||
|                 # our supporting edge is a straight line | ||||
|                 if (@{$edges[0]} > 2) { | ||||
|                     my $line = Slic3r::Line->new($edges[0]->[0], $edges[0]->[-1]); | ||||
|                     $bridge_angle = rad2deg_dir($line->direction); | ||||
|                     $bridge_angle = Slic3r::Geometry::rad2deg_dir($line->direction); | ||||
|                 } | ||||
|             } elsif (@edges) { | ||||
|                 my $center = bounding_box_center([ map @$_, @edges ]); | ||||
|                 my $center = Slic3r::Geometry::bounding_box_center([ map @$_, @edges ]); | ||||
|                 my $x = my $y = 0; | ||||
|                 foreach my $point (map @$, @edges) { | ||||
|                     my $line = Slic3r::Line->new($center, $point); | ||||
|  | @ -430,7 +430,7 @@ sub process_bridges { | |||
|                     $x += cos($dir) * $len; | ||||
|                     $y += sin($dir) * $len; | ||||
|                 } | ||||
|                 $bridge_angle = rad2deg_dir(atan2($y, $x)); | ||||
|                 $bridge_angle = Slic3r::Geometry::rad2deg_dir(atan2($y, $x)); | ||||
|             } | ||||
|              | ||||
|             Slic3r::debugf "  Optimal infill angle of bridge on layer %d is %d degrees\n", | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ use File::Spec; | |||
| use List::Util qw(max); | ||||
| use Math::ConvexHull 1.0.4 qw(convex_hull); | ||||
| use Slic3r::ExtrusionPath ':roles'; | ||||
| use Slic3r::Geometry qw(X Y Z X1 Y1 X2 Y2 PI scale unscale move_points nearest_point); | ||||
| use Slic3r::Geometry qw(X Y Z X1 Y1 X2 Y2 MIN PI scale unscale move_points nearest_point); | ||||
| use Slic3r::Geometry::Clipper qw(diff_ex union_ex intersection_ex offset JT_ROUND JT_SQUARE); | ||||
| use Time::HiRes qw(gettimeofday tv_interval); | ||||
| 
 | ||||
|  | @ -115,20 +115,30 @@ sub add_model { | |||
|              | ||||
|             $mesh->rotate($Slic3r::Config->rotate); | ||||
|             $mesh->scale($Slic3r::Config->scale / &Slic3r::SCALING_FACTOR); | ||||
|             $mesh->align_to_origin; | ||||
|         } | ||||
|              | ||||
|          | ||||
|         my $complete_mesh = Slic3r::TriangleMesh->merge(grep defined $_, @meshes); | ||||
|          | ||||
|         # initialize print object | ||||
|         push @{$self->objects}, Slic3r::Print::Object->new( | ||||
|         my $print_object = Slic3r::Print::Object->new( | ||||
|             print       => $self, | ||||
|             meshes      => [ @meshes ], | ||||
|             size        => [ $object->mesh->size ], | ||||
|             size        => [ $complete_mesh->size ], | ||||
|             input_file  => $object->input_file | ||||
|         ); | ||||
|         push @{$self->objects}, $print_object; | ||||
|          | ||||
|         # align object to origin | ||||
|         { | ||||
|             my @extents = $complete_mesh->extents; | ||||
|             foreach my $mesh (grep defined $_, @meshes) { | ||||
|                 $mesh->move(map -$extents[$_][MIN], X,Y,Z); | ||||
|             } | ||||
|         } | ||||
|          | ||||
|         if ($object->instances) { | ||||
|             # replace the default [0,0] instance with the custom ones | ||||
|             @{$self->objects->[-1]->copies} = map [ scale $_->offset->[X], scale $_->offset->[Y] ], @{$object->instances}; | ||||
|             @{$print_object->copies} = map [ scale $_->offset->[X], scale $_->offset->[Y] ], @{$object->instances}; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -529,12 +529,12 @@ sub generate_support_material { | |||
|              | ||||
|             @current_support_regions = @{diff_ex( | ||||
|                 [ map @$_, @current_support_regions ], | ||||
|                 [ map @{$_->expolygon}, @{$layer->slices} ], | ||||
|                 [ map @$_, @{$layer->slices} ], | ||||
|             )}; | ||||
|              | ||||
|             $layers{$i} = diff_ex( | ||||
|                 [ map @$_, @current_support_regions ], | ||||
|                 [ map @$_, map $_->expolygon->offset_ex($distance_from_object),  @{$layer->slices} ], | ||||
|                 [ map @$_, map $_->offset_ex($distance_from_object), @{$layer->slices} ], | ||||
|             ); | ||||
|             $_->simplify(scale $Slic3r::support_material_flow->spacing * 2) for @{$layers{$i}}; | ||||
|              | ||||
|  | @ -543,8 +543,8 @@ sub generate_support_material { | |||
|             my @overhangs = (); | ||||
|             if ($lower_layer) { | ||||
|                 @overhangs = map $_->offset_ex(2 * $overhang_width), @{diff_ex( | ||||
|                     [ map @$_, map $_->expolygon->offset_ex(-$overhang_width), @{$layer->slices} ], | ||||
|                     [ map @{$_->expolygon}, @{$lower_layer->slices} ], | ||||
|                     [ map @$_, map $_->offset_ex(-$overhang_width), @{$layer->slices} ], | ||||
|                     [ map @$_, @{$lower_layer->slices} ], | ||||
|                     1, | ||||
|                 )}; | ||||
|             } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci