Add FE_NONE with value 0 and increment FE_TOP and FE_BOTTOM to simplify

and correct logic.
This commit is contained in:
Mark Hindess 2012-05-09 19:57:00 +01:00
parent 9d9cef2145
commit 5ebf6a71cd

View file

@ -23,8 +23,9 @@ use constant I_PREV_FACET_INDEX => 4;
use constant I_NEXT_FACET_INDEX => 5; use constant I_NEXT_FACET_INDEX => 5;
use constant I_FACET_EDGE => 6; use constant I_FACET_EDGE => 6;
use constant FE_TOP => 0; use constant FE_NONE => 0;
use constant FE_BOTTOM => 1; use constant FE_TOP => 1;
use constant FE_BOTTOM => 2;
# always make sure BUILD is idempotent # always make sure BUILD is idempotent
sub BUILD { sub BUILD {
@ -144,11 +145,11 @@ sub make_loops {
# remove tangent edges # remove tangent edges
{ {
for (my $i = 0; $i <= $#lines; $i++) { for (my $i = 0; $i <= $#lines; $i++) {
next unless defined $lines[$i] && defined $lines[$i][I_FACET_EDGE]; next unless defined $lines[$i] && $lines[$i][I_FACET_EDGE];
# if the line is a facet edge, find another facet edge # if the line is a facet edge, find another facet edge
# having the same endpoints but in reverse order # having the same endpoints but in reverse order
for (my $j = $i+1; $j <= $#lines; $j++) { for (my $j = $i+1; $j <= $#lines; $j++) {
next unless defined $lines[$j] && defined $lines[$j][I_FACET_EDGE]; next unless defined $lines[$j] && $lines[$j][I_FACET_EDGE];
# are these facets adjacent? (sharing a common edge on this layer) # are these facets adjacent? (sharing a common edge on this layer)
if ($lines[$i][I_A_ID] == $lines[$j][I_B_ID] && $lines[$i][I_B_ID] == $lines[$j][I_A_ID]) { if ($lines[$i][I_A_ID] == $lines[$j][I_B_ID] && $lines[$i][I_B_ID] == $lines[$j][I_A_ID]) {
@ -156,7 +157,8 @@ sub make_loops {
# if they are both oriented upwards or downwards (like a 'V') # if they are both oriented upwards or downwards (like a 'V')
# then we can remove both edges from this layer since it won't # then we can remove both edges from this layer since it won't
# affect the sliced shape # affect the sliced shape
if ($lines[$j][I_FACET_EDGE] == $lines[$i][I_FACET_EDGE]) { if ($lines[$j][I_FACET_EDGE] &&
$lines[$j][I_FACET_EDGE] == $lines[$i][I_FACET_EDGE]) {
$lines[$i] = undef; $lines[$i] = undef;
$lines[$j] = undef; $lines[$j] = undef;
last; last;
@ -208,8 +210,8 @@ sub make_loops {
if (0) { if (0) {
require "Slic3r/SVG.pm"; require "Slic3r/SVG.pm";
Slic3r::SVG::output(undef, "same_point.svg", Slic3r::SVG::output(undef, "same_point.svg",
lines => [ map $_->line, grep !defined $_->[I_FACET_EDGE], @lines ], lines => [ map $_->line, grep !$_->[I_FACET_EDGE], @lines ],
red_lines => [ map $_->line, grep defined $_->[I_FACET_EDGE], @lines ], red_lines => [ map $_->line, grep $_->[I_FACET_EDGE], @lines ],
points => [ $self->vertices->[$point_id] ], points => [ $self->vertices->[$point_id] ],
no_arrows => 0, no_arrows => 0,
); );
@ -482,7 +484,7 @@ sub intersect_facet {
$facet_id, # I_FACET_INDEX $facet_id, # I_FACET_INDEX
$prev_facet_index, # I_PREV_FACET_INDEX $prev_facet_index, # I_PREV_FACET_INDEX
$next_facet_index, # I_NEXT_FACET_INDEX $next_facet_index, # I_NEXT_FACET_INDEX
undef, # I_FACET_EDGE FE_NONE, # I_FACET_EDGE
# Unused data: # Unused data:
# a => [$points[B][X], $points[B][Y]], # a => [$points[B][X], $points[B][Y]],