Small fix/improvement for the vertex indexing

This commit is contained in:
Alessandro Ranellucci 2012-02-17 14:58:13 +01:00
parent f814ccf062
commit 94c1b043e3

View file

@ -43,13 +43,14 @@ sub read_file {
my $vertices = []; my $vertices = [];
{ {
my %vertices_map = (); my %vertices_map = ();
foreach my $facet (@$facets) { for (my $f = 0; $f <= $#$facets; $f++) {
for (1..3) { for (1..3) {
if ($vertices_map{$facet->[$_]}) { my $point_id = join ',', @{$facets->[$f][$_]};
$facet->[$_] = $vertices_map{$facet->[$_]}; if (exists $vertices_map{$point_id}) {
$facets->[$f][$_] = $vertices_map{$point_id};
} else { } else {
push @$vertices, $facet->[$_]; push @$vertices, $facets->[$f][$_];
$facet->[$_] = $vertices_map{$facet->[$_]} = $#$vertices; $facets->[$f][$_] = $vertices_map{$point_id} = $#$vertices;
} }
} }
} }