Fixed wrong implementation of concave_points() and convex_points() in C++. #2384

This commit is contained in:
Alessandro Ranellucci 2014-12-07 19:53:22 +01:00
parent 95f7bcb9fe
commit 6ce651eb4a
7 changed files with 53 additions and 18 deletions

View file

@ -2,7 +2,7 @@ use Test::More;
use strict;
use warnings;
plan tests => 33;
plan tests => 38;
BEGIN {
use FindBin;
@ -213,3 +213,29 @@ my $polygons = [
is scalar(@{$square->concave_points(PI*4/3)}), 0, 'no concave vertices detected in convex polygon';
is scalar(@{$square->convex_points(PI*2/3)}), 4, 'four convex vertices detected in square';
}
{
my $triangle = Slic3r::Polygon->new(
[16000170,26257364], [714223,461012], [31286371,461008],
);
is scalar(@{$triangle->concave_points(PI*4/3)}), 0, 'no concave vertices detected in triangle';
is scalar(@{$triangle->convex_points(PI*2/3)}), 3, 'three convex vertices detected in triangle';
}
{
my $triangle = Slic3r::Polygon->new(
[16000170,26257364], [714223,461012], [20000000,461012], [31286371,461012],
);
is scalar(@{$triangle->concave_points(PI*4/3)}), 0, 'no concave vertices detected in triangle having collinear point';
is scalar(@{$triangle->convex_points(PI*2/3)}), 3, 'three convex vertices detected in triangle having collinear point';
}
{
my $triangle = Slic3r::Polygon->new(
[16000170,26257364], [714223,461012], [31286371,461008],
);
my $simplified = $triangle->simplify(250000)->[0];
is scalar(@$simplified), 3, 'triangle is never simplified to less than 3 points';
}
__END__

View file

@ -266,7 +266,7 @@ use Slic3r::Test;
my $was_extruding = 0;
my @seam_points = ();
my $print = Slic3r::Test::init_print($model_name, config => $config);
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
Slic3r::GCode::Reader->new->parse(my $gcode = Slic3r::Test::gcode($print), sub {
my ($self, $cmd, $args, $info) = @_;
if ($info->{extruding}) {