mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
Use Clipper for line clipping
This commit is contained in:
parent
1d6a18071a
commit
3025c77675
20 changed files with 202 additions and 211 deletions
|
@ -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);
|
||||
use Slic3r::Geometry::Clipper qw(diff_ex offset intersection_pl);
|
||||
|
||||
# clearance (in mm) from the perimeters
|
||||
has '_inner_margin' => (is => 'ro', default => sub { scale 0.5 });
|
||||
|
@ -91,7 +91,7 @@ sub BUILD {
|
|||
for my $m (0 .. $#{$outer[$i]}) {
|
||||
for my $n (0 .. $#{$outer[$j]}) {
|
||||
my $line = Slic3r::Line->new($outer[$i][$m], $outer[$j][$n]);
|
||||
if (!@{Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection([ map $_->pp, @outer_ex ], [$line->pp])}) {
|
||||
if (!@{intersection_pl([$line->as_polyline], [ map @$_, @outer_ex ])}) {
|
||||
# this line does not cross any polygon
|
||||
my $dist = $line->length;
|
||||
$edges->{$outer[$i][$m]}{$outer[$j][$n]} = $dist;
|
||||
|
@ -112,7 +112,7 @@ sub BUILD {
|
|||
for my $m (0 .. $#{$inner[$i]}) {
|
||||
for my $n (0 .. $#{$inner[$j]}) {
|
||||
my $line = Slic3r::Line->new($inner[$i][$m], $inner[$j][$n]);
|
||||
if (!@{Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection([ map $_->pp, @inner_ex ], [$line->pp])}) {
|
||||
if (!@{intersection_pl([$line->as_polyline], [ map @$_, @inner_ex ])}) {
|
||||
# this line does not cross any polygon
|
||||
my $dist = $line->length * CROSSING_FACTOR;
|
||||
$edges->{$inner[$i][$m]}{$inner[$j][$n]} = $dist;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue