mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 22:54:08 -06:00
Show vertical projection instead of convex hull for objects with <= 2000 facets. #780
This commit is contained in:
parent
e6afebb982
commit
116ab446e3
3 changed files with 76 additions and 16 deletions
|
@ -2,6 +2,7 @@ package Slic3r::TriangleMesh;
|
|||
use Moo;
|
||||
|
||||
use Slic3r::Geometry qw(X Y Z A B unscale same_point);
|
||||
use Slic3r::Geometry::Clipper qw(union_ex);
|
||||
|
||||
# public
|
||||
has 'vertices' => (is => 'ro', required => 1); # id => [$x,$y,$z]
|
||||
|
@ -578,4 +579,18 @@ sub split_mesh {
|
|||
return @meshes;
|
||||
}
|
||||
|
||||
sub horizontal_projection {
|
||||
my $self = shift;
|
||||
|
||||
my @f = ();
|
||||
foreach my $facet (@{$self->facets}) {
|
||||
push @f, [ map [ @{$self->vertices->[$_]}[X,Y] ], @$facet ];
|
||||
}
|
||||
|
||||
my $scale_vector = Math::Clipper::integerize_coordinate_sets({ bits => 32 }, @f);
|
||||
my $union = union_ex([ Slic3r::Geometry::Clipper::offset(\@f, 1) ]);
|
||||
Math::Clipper::unscale_coordinate_sets($scale_vector, $_) for @$union;
|
||||
return $union;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue