mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-15 18:58:00 -06:00
Fixed everything in the XS port
This commit is contained in:
parent
49040db9a3
commit
443d4e52cb
8 changed files with 62 additions and 58 deletions
|
@ -60,11 +60,6 @@ sub offset_ex {
|
|||
return Slic3r::Geometry::Clipper::offset_ex(\@$self, @_);
|
||||
}
|
||||
|
||||
sub safety_offset {
|
||||
my $self = shift;
|
||||
return Slic3r::Geometry::Clipper::safety_offset_ex(\@$self, @_);
|
||||
}
|
||||
|
||||
sub noncollapsing_offset_ex {
|
||||
my $self = shift;
|
||||
my ($distance, @params) = @_;
|
||||
|
|
|
@ -956,7 +956,7 @@ sub repaint {
|
|||
@{$parent->{object_previews}} = ();
|
||||
for my $obj_idx (0 .. $#{$parent->{objects}}) {
|
||||
my $object = $parent->{objects}[$obj_idx];
|
||||
next unless defined $object->thumbnail && @{$object->thumbnail};
|
||||
next unless defined $object->thumbnail;
|
||||
for my $instance_idx (0 .. $#{$object->instances}) {
|
||||
my $instance = $object->instances->[$instance_idx];
|
||||
|
||||
|
@ -973,7 +973,7 @@ sub repaint {
|
|||
} else {
|
||||
$dc->SetBrush($parent->{objects_brush});
|
||||
}
|
||||
$dc->DrawPolygon($parent->_y($_), 0, 0) for map $_->contour, @{ $parent->{object_previews}->[-1][2] };
|
||||
$dc->DrawPolygon($parent->_y($_), 0, 0) for map $_->contour->pp, @{ $parent->{object_previews}->[-1][2] };
|
||||
|
||||
# if sequential printing is enabled and we have more than one object
|
||||
if ($parent->{config}->complete_objects && (map @{$_->instances}, @{$parent->{objects}}) > 1) {
|
||||
|
@ -988,7 +988,7 @@ sub repaint {
|
|||
|
||||
# draw skirt
|
||||
if (@{$parent->{object_previews}} && $parent->{config}->skirts) {
|
||||
my $convex_hull = Slic3r::Polygon->new(@{convex_hull([ map @{$_->contour}, map @{$_->[2]}, @{$parent->{object_previews}} ])});
|
||||
my $convex_hull = Slic3r::Polygon->new(@{convex_hull([ map @{$_->contour->pp}, map @{$_->[2]}, @{$parent->{object_previews}} ])});
|
||||
($convex_hull) = @{offset([$convex_hull], $parent->{config}->skirt_distance * $parent->{scaling_factor}, 100, JT_ROUND)};
|
||||
$dc->SetPen($parent->{skirt_pen});
|
||||
$dc->SetBrush($parent->{transparent_brush});
|
||||
|
@ -1003,7 +1003,7 @@ sub mouse_event {
|
|||
my $parent = $self->GetParent;
|
||||
|
||||
my $point = $event->GetPosition;
|
||||
my $pos = $parent->_y([[$point->x, $point->y]])->[0]; #]]
|
||||
my $pos = Slic3r::Point->new(map @$_, map @$_, $parent->_y([[$point->x, $point->y]])); #]]
|
||||
if ($event->ButtonDown(&Wx::wxMOUSE_BTN_LEFT)) {
|
||||
$parent->{selected_objects} = [];
|
||||
$parent->{list}->Select($parent->{list}->GetFirstSelected, 0);
|
||||
|
|
|
@ -4,7 +4,7 @@ use warnings;
|
|||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(safety_offset safety_offset_ex offset offset_ex collapse_ex
|
||||
our @EXPORT_OK = qw(offset offset_ex
|
||||
diff_ex diff union_ex intersection_ex xor_ex PFT_EVENODD JT_MITER JT_ROUND
|
||||
JT_SQUARE is_counter_clockwise union_pt offset2 offset2_ex traverse_pt
|
||||
intersection union);
|
||||
|
@ -13,31 +13,20 @@ use Math::Clipper 1.22 qw(:cliptypes :polyfilltypes :jointypes is_counter_clockw
|
|||
use Slic3r::Geometry qw(scale);
|
||||
our $clipper = Math::Clipper->new;
|
||||
|
||||
sub safety_offset {
|
||||
sub _safety_offset {
|
||||
my ($polygons, $factor) = @_;
|
||||
return [ map Slic3r::Polygon->new(@$_),
|
||||
@{Math::Clipper::int_offset(_convert($polygons), $factor // (scale 1e-05), 100000, JT_MITER, 2)} ];
|
||||
}
|
||||
|
||||
sub safety_offset_ex {
|
||||
my ($polygons, $factor) = @_;
|
||||
return map Slic3r::ExPolygon->new($_->{outer}, @{$_->{holes}}),
|
||||
@{Math::Clipper::ex_int_offset(_convert($polygons), $factor // (scale 1e-05), 100000, JT_MITER, 2)};
|
||||
}
|
||||
|
||||
sub union_pt {
|
||||
my ($polygons, $jointype, $safety_offset) = @_;
|
||||
$jointype = PFT_NONZERO unless defined $jointype;
|
||||
$clipper->clear;
|
||||
$clipper->add_subject_polygons($safety_offset ? _convert(safety_offset($polygons)) : _convert($polygons));
|
||||
$clipper->add_subject_polygons($safety_offset ? _convert(_safety_offset($polygons)) : _convert($polygons));
|
||||
return $clipper->pt_execute(CT_UNION, $jointype, $jointype);
|
||||
}
|
||||
|
||||
sub collapse_ex {
|
||||
my ($polygons, $width) = @_;
|
||||
return offset2_ex($polygons, -$width/2, +$width/2);
|
||||
}
|
||||
|
||||
sub traverse_pt {
|
||||
my ($polynodes) = @_;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ use Moo;
|
|||
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(safety_offset union_ex diff_ex intersection_ex
|
||||
use Slic3r::Geometry::Clipper qw(union_ex diff_ex intersection_ex
|
||||
offset offset2 offset2_ex PFT_EVENODD union_pt traverse_pt diff intersection
|
||||
union diff);
|
||||
use Slic3r::Surface ':types';
|
||||
|
|
|
@ -565,7 +565,7 @@ sub horizontal_projection {
|
|||
$_->make_counter_clockwise for @f; # do this after scaling, as winding order might change while doing that
|
||||
|
||||
# the offset factor was tuned using groovemount.stl
|
||||
return union_ex([ offset(\@f, Slic3r::Geometry::scale 0.01) ], 1);
|
||||
return union_ex(offset(\@f, Slic3r::Geometry::scale 0.01), 1);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue