mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-11-01 21:21:10 -06:00
Ported some minor methods to XS
This commit is contained in:
parent
379cde30e2
commit
28466750e6
9 changed files with 58 additions and 42 deletions
|
|
@ -5,8 +5,6 @@ use warnings;
|
|||
# a line is a two-points line
|
||||
use parent 'Slic3r::Polyline';
|
||||
|
||||
use Slic3r::Geometry qw(A B X Y);
|
||||
|
||||
sub intersection {
|
||||
my $self = shift;
|
||||
my ($line, $require_crossing) = @_;
|
||||
|
|
|
|||
|
|
@ -5,15 +5,7 @@ use warnings;
|
|||
# a polygon is a closed polyline.
|
||||
use parent 'Slic3r::Polyline';
|
||||
|
||||
use Slic3r::Geometry qw(
|
||||
polygon_segment_having_point
|
||||
PI X1 X2 Y1 Y2 epsilon scaled_epsilon);
|
||||
use Slic3r::Geometry::Clipper qw(intersection_pl);
|
||||
|
||||
sub wkt {
|
||||
my $self = shift;
|
||||
return sprintf "POLYGON((%s))", join ',', map "$_->[0] $_->[1]", @$self;
|
||||
}
|
||||
use Slic3r::Geometry qw(PI);
|
||||
|
||||
sub dump_perl {
|
||||
my $self = shift;
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@ package Slic3r::Polyline;
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
use List::Util qw(first);
|
||||
use Slic3r::Geometry qw(X Y PI epsilon);
|
||||
use Slic3r::Geometry::Clipper qw(JT_SQUARE);
|
||||
use Slic3r::Geometry qw(X Y);
|
||||
|
||||
sub new_scale {
|
||||
my $class = shift;
|
||||
|
|
@ -12,29 +10,4 @@ sub new_scale {
|
|||
return $class->new(map [ Slic3r::Geometry::scale($_->[X]), Slic3r::Geometry::scale($_->[Y]) ], @points);
|
||||
}
|
||||
|
||||
sub wkt {
|
||||
my $self = shift;
|
||||
return sprintf "LINESTRING((%s))", join ',', map "$_->[0] $_->[1]", @$self;
|
||||
}
|
||||
|
||||
sub bounding_box {
|
||||
my $self = shift;
|
||||
return Slic3r::Geometry::BoundingBox->new_from_points([ @$self ]);
|
||||
}
|
||||
|
||||
sub size {
|
||||
my $self = shift;
|
||||
return [ Slic3r::Geometry::size_2D($self) ];
|
||||
}
|
||||
|
||||
sub is_straight {
|
||||
my ($self) = @_;
|
||||
|
||||
# Check that each segment's direction is equal to the line connecting
|
||||
# first point and last point. (Checking each line against the previous
|
||||
# one would have caused the error to accumulate.)
|
||||
my $dir = Slic3r::Line->new($self->first_point, $self->last_point)->direction;
|
||||
return !defined first { !$_->parallel_to($dir) } @{$self->lines};
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue