Bugfixes and improvements in surface detection

This commit is contained in:
Alessandro Ranellucci 2011-10-04 22:27:45 +02:00
parent f1a36502e1
commit 2da5ee7448
13 changed files with 202 additions and 67 deletions

View file

@ -10,10 +10,10 @@ has 'points' => (
sub cast {
my $class = shift;
my ($line) = @_;
my ($line, %args) = @_;
if (ref $line eq 'ARRAY') {
@$line == 2 or die "Line needs two points!";
return Slic3r::Line->new(points => [ map Slic3r::Point->cast($_), @$line ]);
return $class->new(points => [ map Slic3r::Point->cast($_), @$line ], %args);
} else {
return $line;
}
@ -51,6 +51,17 @@ sub has_endpoint {
return $point->coincides_with($self->a) || $point->coincides_with($self->b);
}
sub has_segment {
my $self = shift;
my ($line) = @_;
$line = $line->p if $line->isa('Slic3r::Line');
# a segment belongs to another segment if its points belong to it
return Slic3r::Geometry::point_in_segment($line->[0], $self->p)
&& Slic3r::Geometry::point_in_segment($line->[1], $self->p);
}
sub parallel_to {
my $self = shift;
my ($line) = @_;