mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Remove useless algorithm in loop merging code
This commit is contained in:
		
							parent
							
								
									3622193c3f
								
							
						
					
					
						commit
						a15884dac9
					
				
					 1 changed files with 26 additions and 67 deletions
				
			
		|  | @ -183,12 +183,11 @@ sub make_loops { | |||
|     my @lines = map unpack_line($_), @$lines; | ||||
|      | ||||
|     # remove tangent edges | ||||
|     { | ||||
|         for (my $i = 0; $i <= $#lines; $i++) { | ||||
|     for my $i (0 .. $#lines) { | ||||
|         next unless defined $lines[$i] && defined $lines[$i][I_FACET_EDGE]; | ||||
|         # if the line is a facet edge, find another facet edge | ||||
|         # having the same endpoints but in reverse order | ||||
|             for (my $j = $i+1; $j <= $#lines; $j++) { | ||||
|         for my $j ($i+1 .. $#lines) { | ||||
|             next unless defined $lines[$j] && defined $lines[$j][I_FACET_EDGE]; | ||||
|              | ||||
|             # are these facets adjacent? (sharing a common edge on this layer) | ||||
|  | @ -214,48 +213,8 @@ sub make_loops { | |||
|              | ||||
|         } | ||||
|     } | ||||
|     } | ||||
|      | ||||
|     @lines = grep $_, @lines; | ||||
|      | ||||
|     # count relationships | ||||
|     my %a_count    = ();  # how many lines have the same a_id | ||||
|     foreach my $line (@lines) { | ||||
|         if (defined $line->[I_A_ID]) { | ||||
|             $a_count{$line->[I_A_ID]}++; | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     foreach my $point_id (grep $a_count{$_} > 1, keys %a_count) { | ||||
|         my @lines_starting_here = grep defined $_->[I_A_ID] && $_->[I_A_ID] == $point_id, @lines; | ||||
|         Slic3r::debugf "%d lines start at point %d\n", scalar(@lines_starting_here), $point_id; | ||||
|          | ||||
|         # if two lines start at this point, one being a 'top' facet edge and the other being a 'bottom' one, | ||||
|         # then remove the top one and those following it (removing the top or the bottom one is an arbitrary | ||||
|         # choice) | ||||
|         # The "// ''" on the next line avoids uninitialized value errors mentioned in issue #357 but these | ||||
|         # errors occur on fixed models so the root cause still needs to be found | ||||
|         if (@lines_starting_here == 2 && join('', sort map $_->[I_FACET_EDGE] // '', @lines_starting_here) eq FE_TOP.FE_BOTTOM) { #/ | ||||
|             my @to_remove = grep $_->[I_FACET_EDGE] == FE_TOP, @lines_starting_here; | ||||
|             while (!grep defined $_->[I_B_ID] && $_->[I_B_ID] == $to_remove[-1]->[I_B_ID] && $_ ne $to_remove[-1], @lines) { | ||||
|                 push @to_remove, grep defined $_->[I_A_ID] && $_->[I_A_ID] == $to_remove[-1]->[I_B_ID], @lines; | ||||
|             } | ||||
|             my %to_remove = map {$_ => 1} @to_remove; | ||||
|             @lines = grep !$to_remove{$_}, @lines; | ||||
|         } else { | ||||
|             Slic3r::debugf "  this shouldn't happen and should be further investigated\n"; | ||||
|             if (0) { | ||||
|                 require "Slic3r/SVG.pm"; | ||||
|                 Slic3r::SVG::output("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] ], | ||||
|                     no_arrows => 0, | ||||
|                 ); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     my (@polygons, @failed_loops) = (); | ||||
|     CYCLE: while (@lines) { | ||||
|         # take first spare line and start a new loop | ||||
|  | @ -287,7 +246,7 @@ sub make_loops { | |||
|             } | ||||
|             push @loop, splice @lines, $line_idx, 1; | ||||
|         } | ||||
|     }; | ||||
|     } | ||||
|      | ||||
|     # TODO: we should try to combine failed loops | ||||
|     for (grep @$_ >= 3, @failed_loops) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci