From 94c1b043e36c2a93348cfb87f78324ee403b3ac0 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 17 Feb 2012 14:58:13 +0100 Subject: [PATCH] Small fix/improvement for the vertex indexing --- lib/Slic3r/STL.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/Slic3r/STL.pm b/lib/Slic3r/STL.pm index 70285a2fb..d27b95096 100644 --- a/lib/Slic3r/STL.pm +++ b/lib/Slic3r/STL.pm @@ -43,13 +43,14 @@ sub read_file { my $vertices = []; { my %vertices_map = (); - foreach my $facet (@$facets) { + for (my $f = 0; $f <= $#$facets; $f++) { for (1..3) { - if ($vertices_map{$facet->[$_]}) { - $facet->[$_] = $vertices_map{$facet->[$_]}; + my $point_id = join ',', @{$facets->[$f][$_]}; + if (exists $vertices_map{$point_id}) { + $facets->[$f][$_] = $vertices_map{$point_id}; } else { - push @$vertices, $facet->[$_]; - $facet->[$_] = $vertices_map{$facet->[$_]} = $#$vertices; + push @$vertices, $facets->[$f][$_]; + $facets->[$f][$_] = $vertices_map{$point_id} = $#$vertices; } } }