Show vertical projection instead of convex hull for objects with <= 2000 facets. #780

This commit is contained in:
Alessandro Ranellucci 2012-11-24 00:13:04 +01:00
parent e6afebb982
commit 116ab446e3
3 changed files with 76 additions and 16 deletions

View file

@ -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;