Ported make_clockwise() and make_counter_clockwise()
This commit is contained in:
parent
fe061b19ad
commit
f7ada2b5db
@ -15,24 +15,6 @@ sub wkt {
|
|||||||
return sprintf "POLYGON((%s))", join ',', map "$_->[0] $_->[1]", @$self;
|
return sprintf "POLYGON((%s))", join ',', map "$_->[0] $_->[1]", @$self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub make_counter_clockwise {
|
|
||||||
my $self = shift;
|
|
||||||
if (!$self->is_counter_clockwise) {
|
|
||||||
$self->reverse;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub make_clockwise {
|
|
||||||
my $self = shift;
|
|
||||||
if ($self->is_counter_clockwise) {
|
|
||||||
$self->reverse;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub merge_continuous_lines {
|
sub merge_continuous_lines {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
|
@ -52,4 +52,24 @@ Polygon::is_counter_clockwise()
|
|||||||
return orientation;
|
return orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Polygon::make_counter_clockwise()
|
||||||
|
{
|
||||||
|
if (!this->is_counter_clockwise()) {
|
||||||
|
this->reverse();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Polygon::make_clockwise()
|
||||||
|
{
|
||||||
|
if (this->is_counter_clockwise()) {
|
||||||
|
this->reverse();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ class Polygon : public MultiPoint {
|
|||||||
Polyline* split_at_index(int index);
|
Polyline* split_at_index(int index);
|
||||||
Polyline* split_at_first_point();
|
Polyline* split_at_first_point();
|
||||||
bool is_counter_clockwise();
|
bool is_counter_clockwise();
|
||||||
|
bool make_counter_clockwise();
|
||||||
|
bool make_clockwise();
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<Polygon> Polygons;
|
typedef std::vector<Polygon> Polygons;
|
||||||
|
@ -4,7 +4,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Slic3r::XS;
|
use Slic3r::XS;
|
||||||
use Test::More tests => 8;
|
use Test::More tests => 10;
|
||||||
|
|
||||||
my $square = [ # ccw
|
my $square = [ # ccw
|
||||||
[100, 100],
|
[100, 100],
|
||||||
@ -35,6 +35,10 @@ ok $polygon->is_counter_clockwise, 'is_counter_clockwise';
|
|||||||
my $clone = $polygon->clone;
|
my $clone = $polygon->clone;
|
||||||
$clone->reverse;
|
$clone->reverse;
|
||||||
ok !$clone->is_counter_clockwise, 'is_counter_clockwise';
|
ok !$clone->is_counter_clockwise, 'is_counter_clockwise';
|
||||||
|
$clone->make_counter_clockwise;
|
||||||
|
ok $clone->is_counter_clockwise, 'make_counter_clockwise';
|
||||||
|
$clone->make_counter_clockwise;
|
||||||
|
ok $clone->is_counter_clockwise, 'make_counter_clockwise';
|
||||||
}
|
}
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
Polyline* split_at_first_point()
|
Polyline* split_at_first_point()
|
||||||
%code{% const char* CLASS = "Slic3r::Polyline"; RETVAL = THIS->split_at_first_point(); %};
|
%code{% const char* CLASS = "Slic3r::Polyline"; RETVAL = THIS->split_at_first_point(); %};
|
||||||
bool is_counter_clockwise();
|
bool is_counter_clockwise();
|
||||||
|
bool make_counter_clockwise();
|
||||||
|
bool make_clockwise();
|
||||||
%{
|
%{
|
||||||
|
|
||||||
Polygon*
|
Polygon*
|
||||||
|
Loading…
Reference in New Issue
Block a user