ExPolygon.pm 756 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package Slic3r::ExPolygon;
  2. use strict;
  3. use warnings;
  4. # an ExPolygon is a polygon with holes
  5. use List::Util qw(first);
  6. use Slic3r::Geometry::Clipper qw(union_ex diff_pl);
  7. sub offset {
  8. my $self = shift;
  9. return Slic3r::Geometry::Clipper::offset(\@$self, @_);
  10. }
  11. sub offset_ex {
  12. my $self = shift;
  13. return Slic3r::Geometry::Clipper::offset_ex(\@$self, @_);
  14. }
  15. sub noncollapsing_offset_ex {
  16. my $self = shift;
  17. my ($distance, @params) = @_;
  18. return $self->offset_ex($distance + 1, @params);
  19. }
  20. sub bounding_box {
  21. my $self = shift;
  22. return $self->contour->bounding_box;
  23. }
  24. package Slic3r::ExPolygon::Collection;
  25. sub size {
  26. my $self = shift;
  27. return [ Slic3r::Geometry::size_2D([ map @$_, map @$_, @$self ]) ];
  28. }
  29. 1;