@@ -15,24 +15,6 @@ sub wkt {
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 {
- if ($self->is_counter_clockwise) {
sub merge_continuous_lines {
my $self = shift;
@@ -52,4 +52,24 @@ Polygon::is_counter_clockwise()
return orientation;
+bool
+Polygon::make_counter_clockwise()
+{
+ if (!this->is_counter_clockwise()) {
+ this->reverse();
+ return true;
+ }
+ return false;
+}
+
+Polygon::make_clockwise()
+ if (this->is_counter_clockwise()) {
@@ -16,6 +16,8 @@ class Polygon : public MultiPoint {
Polyline* split_at_index(int index);
Polyline* split_at_first_point();
bool is_counter_clockwise();
+ bool make_counter_clockwise();
+ bool make_clockwise();
};
typedef std::vector<Polygon> Polygons;
@@ -4,7 +4,7 @@ use strict;
use warnings;
use Slic3r::XS;
-use Test::More tests => 8;
+use Test::More tests => 10;
my $square = [ # ccw
[100, 100],
@@ -35,6 +35,10 @@ ok $polygon->is_counter_clockwise, 'is_counter_clockwise';
my $clone = $polygon->clone;
$clone->reverse;
ok !$clone->is_counter_clockwise, 'is_counter_clockwise';
+ $clone->make_counter_clockwise;
+ ok $clone->is_counter_clockwise, 'make_counter_clockwise';
__END__
@@ -22,6 +22,8 @@
Polyline* split_at_first_point()
%code{% const char* CLASS = "Slic3r::Polyline"; RETVAL = THIS->split_at_first_point(); %};
%{
Polygon*