mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Large memory savings (down to about 50%) for high-res input files
This commit is contained in:
		
							parent
							
								
									efdf266df1
								
							
						
					
					
						commit
						34e3dfdb08
					
				
					 3 changed files with 26 additions and 25 deletions
				
			
		|  | @ -207,10 +207,7 @@ sub export_gcode { | |||
|     # each layer has surfaces with holes | ||||
|     $status_cb->(5, "Processing input file");     | ||||
|     $status_cb->(10, "Processing triangulated mesh"); | ||||
|     $_->slice for @{$self->objects}; | ||||
|     unless ($params{keep_meshes}) { | ||||
|         $_->mesh(undef) for @{$self->objects};  # free memory | ||||
|     } | ||||
|     $_->slice(keep_meshes => $params{keep_meshes}) for @{$self->objects}; | ||||
|      | ||||
|     # make perimeters | ||||
|     # this will add a set of extrusion loops to each layer | ||||
|  |  | |||
|  | @ -40,6 +40,7 @@ sub layer { | |||
| 
 | ||||
| sub slice { | ||||
|     my $self = shift; | ||||
|     my %params = @_; | ||||
|      | ||||
|     # process facets | ||||
|     { | ||||
|  | @ -78,6 +79,9 @@ sub slice { | |||
|     } | ||||
|     die "Invalid input file\n" if !@{$self->layers}; | ||||
|      | ||||
|     # free memory | ||||
|     $self->mesh(undef) unless $params{keep_meshes}; | ||||
|      | ||||
|     # remove last layer if empty | ||||
|     # (we might have created it because of the $max_layer = ... + 1 code below) | ||||
|     pop @{$self->layers} if !@{$self->layers->[-1]->surfaces} && !@{$self->layers->[-1]->lines}; | ||||
|  | @ -94,7 +98,7 @@ sub slice { | |||
|         # inside a closed polyline) | ||||
|          | ||||
|         # build surfaces from sparse lines | ||||
|         $layer->make_surfaces($self->mesh->make_loops($layer)); | ||||
|         $layer->make_surfaces(Slic3r::TriangleMesh::make_loops($layer)); | ||||
|          | ||||
|         # free memory | ||||
|         $layer->lines(undef); | ||||
|  |  | |||
|  | @ -136,10 +136,15 @@ sub check_manifoldness { | |||
| } | ||||
| 
 | ||||
| sub make_loops { | ||||
|     my $self = shift; | ||||
|     my ($layer) = @_; | ||||
|      | ||||
|     my @lines = @{$layer->lines}; | ||||
|     my @lines = map { | ||||
|         my @data = unpack 'ffLLLLLc', $_; | ||||
|         splice @data, 0, 2, [ @data[0,1] ]; | ||||
|         $data[$_] ||= undef for I_A_ID, I_B_ID; | ||||
|         $data[I_FACET_EDGE] = undef if $data[I_FACET_EDGE] == -1; | ||||
|         [@data] | ||||
|     } @{$layer->lines}; | ||||
|      | ||||
|     # remove tangent edges | ||||
|     { | ||||
|  | @ -212,7 +217,7 @@ sub make_loops { | |||
|                 Slic3r::SVG::output(undef, "same_point.svg", | ||||
|                     lines       => [ map $_->line, grep !defined $_->[I_FACET_EDGE], @lines ], | ||||
|                     red_lines   => [ map $_->line, grep defined $_->[I_FACET_EDGE], @lines ], | ||||
|                     points      => [ $self->vertices->[$point_id] ], | ||||
|                     #points      => [ $self->vertices->[$point_id] ], | ||||
|                     no_arrows => 0, | ||||
|                 ); | ||||
|             } | ||||
|  | @ -417,8 +422,8 @@ sub intersect_facet { | |||
|                 ($a, $b) = ($b, $a); | ||||
|                 ($a_id, $b_id) = ($b_id, $a_id); | ||||
|             } | ||||
|             push @lines, [ | ||||
|                 [$b->[X], $b->[Y]],     # I_B | ||||
|             push @lines, pack 'ffLLLLLc', ( | ||||
|                 $b->[X], $b->[Y],       # I_B | ||||
|                 $a_id,                  # I_A_ID | ||||
|                 $b_id,                  # I_B_ID | ||||
|                 $facet_id,              # I_FACET_INDEX | ||||
|  | @ -428,7 +433,7 @@ sub intersect_facet { | |||
|                  | ||||
|                 # Unused data: | ||||
|                 # a             => [$a->[X], $a->[Y]], | ||||
|             ]; | ||||
|             ); | ||||
|             #print "Horizontal edge at $z!\n"; | ||||
|              | ||||
|         } elsif ($a->[Z] == $z) { | ||||
|  | @ -477,20 +482,15 @@ sub intersect_facet { | |||
|         $next_facet_index = +(grep $_ != $facet_id, @{$self->edges_facets->[$points[A][3]]})[0] | ||||
|             if defined $points[A][3]; | ||||
|          | ||||
|         return [ | ||||
|             [$points[A][X], $points[A][Y]],     # I_B | ||||
|             $points[B][2],                      # I_A_ID | ||||
|             $points[A][2],                      # I_B_ID | ||||
|             $facet_id,                          # I_FACET_INDEX | ||||
|             $prev_facet_index,                  # I_PREV_FACET_INDEX | ||||
|             $next_facet_index,                  # I_NEXT_FACET_INDEX | ||||
|             undef,                              # I_FACET_EDGE | ||||
|              | ||||
|             # Unused data: | ||||
|             # a             => [$points[B][X], $points[B][Y]], | ||||
|             # prev_edge_id  => $points[B][3], | ||||
|             # next_edge_id  => $points[A][3], | ||||
|         ]; | ||||
|         return pack 'ffLLLLLc', ( | ||||
|             $points[A][X], $points[A][Y],   # I_B | ||||
|             $points[B][2] || 0,             # I_A_ID | ||||
|             $points[A][2] || 0,             # I_B_ID | ||||
|             $facet_id,                      # I_FACET_INDEX | ||||
|             $prev_facet_index,              # I_PREV_FACET_INDEX | ||||
|             $next_facet_index,              # I_NEXT_FACET_INDEX | ||||
|             -1,                             # I_FACET_EDGE | ||||
|         ); | ||||
|         #printf "  intersection points at z = %f: %f,%f - %f,%f\n", $z, map @$_, @intersection_points; | ||||
|     } | ||||
|      | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci