Removed dependency on Math::Clipper

This commit is contained in:
Alessandro Ranellucci 2013-08-27 01:26:44 +02:00
parent b11b595c97
commit fb763b0187
21 changed files with 82 additions and 76 deletions

View file

@ -8,7 +8,7 @@ use Boost::Geometry::Utils;
use List::Util qw(first);
use Math::Geometry::Voronoi;
use Slic3r::Geometry qw(X Y A B point_in_polygon same_line epsilon);
use Slic3r::Geometry::Clipper qw(union_ex JT_MITER);
use Slic3r::Geometry::Clipper qw(union_ex);
sub wkt {
my $self = shift;

View file

@ -4,7 +4,7 @@ use Moo;
extends 'Slic3r::Fill::Base';
use Slic3r::Geometry qw(scale unscale X);
use Slic3r::Geometry::Clipper qw(offset offset2 union_pt traverse_pt PFT_EVENODD);
use Slic3r::Geometry::Clipper qw(offset offset2 union_pt traverse_pt);
sub fill_surface {
my $self = shift;

View file

@ -14,7 +14,7 @@ has '_tolerance' => (is => 'lazy');
use List::Util qw(first);
use Slic3r::Geometry qw(A B scale epsilon);
use Slic3r::Geometry::Clipper qw(diff_ex offset JT_MITER);
use Slic3r::Geometry::Clipper qw(diff_ex offset);
# clearance (in mm) from the perimeters
has '_inner_margin' => (is => 'ro', default => sub { scale 0.5 });

View file

@ -5,7 +5,7 @@ use utf8;
use File::Basename qw(basename dirname);
use List::Util qw(max sum first);
use Math::Clipper qw(offset JT_ROUND);
use Slic3r::Geometry::Clipper qw(offset JT_ROUND);
use Math::ConvexHull::MonotoneChain qw(convex_hull);
use Slic3r::Geometry qw(X Y Z MIN MAX);
use threads::shared qw(shared_clone);
@ -681,7 +681,6 @@ sub export_gcode {
sub export_gcode2 {
my $self = shift;
my ($print, $output_file, %params) = @_;
$Slic3r::Geometry::Clipper::clipper = Math::Clipper->new;
local $SIG{'KILL'} = sub {
Slic3r::debugf "Exporting cancelled; exiting thread...\n";
threads->exit();
@ -822,7 +821,6 @@ sub make_thumbnail {
my $object = $self->{objects}[$obj_idx];
$object->thumbnail_scaling_factor($self->{scaling_factor});
my $cb = sub {
$Slic3r::Geometry::Clipper::clipper = Math::Clipper->new if $Slic3r::have_threads;
my $thumbnail = $object->make_thumbnail;
if ($Slic3r::have_threads) {

View file

@ -792,14 +792,13 @@ sub chained_path {
my %indices = map { $points[$_] => $_ } 0 .. $#points;
my @result = ();
my $last_point;
if (!$start_near) {
if (!$start_near && @points) {
$start_near = shift @points;
push @result, $indices{$start_near} if $start_near;
push @result, $indices{$start_near};
}
while (@points) {
$start_near = $start_near->nearest_point(\@points);
@points = grep $_ ne $start_near, @points;
my $idx = $start_near->nearest_point_index(\@points);
my ($start_near) = splice @points, $idx, 1;
push @result, $indices{$start_near};
}

View file

@ -5,13 +5,11 @@ use warnings;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(offset offset_ex
diff_ex diff union_ex intersection_ex xor_ex PFT_EVENODD JT_MITER JT_ROUND
diff_ex diff union_ex intersection_ex xor_ex JT_ROUND
JT_SQUARE is_counter_clockwise union_pt offset2 offset2_ex traverse_pt
intersection union);
use Math::Clipper 1.22 qw(:cliptypes :polyfilltypes :jointypes is_counter_clockwise area);
use Slic3r::Geometry qw(scale);
our $clipper = Math::Clipper->new;
sub traverse_pt {
my ($polynodes) = @_;

View file

@ -5,7 +5,7 @@ use List::Util qw(sum first);
use Slic3r::ExtrusionPath ':roles';
use Slic3r::Geometry qw(PI A B scale chained_path_items points_coincide);
use Slic3r::Geometry::Clipper qw(union_ex diff_ex intersection_ex
offset offset2 offset2_ex PFT_EVENODD union_pt traverse_pt diff intersection
offset offset2 offset2_ex union_pt traverse_pt diff intersection
union diff);
use Slic3r::Surface ':types';

View file

@ -8,7 +8,7 @@ use Math::ConvexHull::MonotoneChain qw(convex_hull);
use Slic3r::ExtrusionPath ':roles';
use Slic3r::Geometry qw(X Y Z X1 Y1 X2 Y2 MIN MAX PI scale unscale move_points chained_path);
use Slic3r::Geometry::Clipper qw(diff_ex union_ex union_pt intersection_ex offset
offset2 traverse_pt JT_ROUND JT_SQUARE PFT_EVENODD);
offset2 traverse_pt JT_ROUND JT_SQUARE);
use Time::HiRes qw(gettimeofday tv_interval);
has 'config' => (is => 'rw', default => sub { Slic3r::Config->new_from_defaults }, trigger => 1);
@ -403,7 +403,6 @@ sub export_gcode {
},
thread_cb => sub {
my $q = shift;
$Slic3r::Geometry::Clipper::clipper = Math::Clipper->new;
while (defined (my $obj_layer = $q->dequeue)) {
my ($obj_idx, $layer_id, $region_id) = @$obj_layer;
my $object = $self->objects->[$obj_idx];

View file

@ -330,7 +330,6 @@ sub make_perimeters {
items => sub { 0 .. ($self->layer_count-1) },
thread_cb => sub {
my $q = shift;
$Slic3r::Geometry::Clipper::clipper = Math::Clipper->new;
while (defined (my $layer_id = $q->dequeue)) {
$self->layers->[$layer_id]->make_perimeters;
}
@ -1235,7 +1234,6 @@ sub generate_support_material {
items => [ 0 .. $#{$self->support_layers} ],
thread_cb => sub {
my $q = shift;
$Slic3r::Geometry::Clipper::clipper = Math::Clipper->new;
my $result = {};
while (defined (my $layer_id = $q->dequeue)) {
$result->{$layer_id} = $process_layer->($layer_id);