Surface.pm 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package Slic3r::Surface;
  2. use strict;
  3. use warnings;
  4. require Exporter;
  5. our @ISA = qw(Exporter);
  6. our @EXPORT_OK = qw(S_TYPE_TOP S_TYPE_BOTTOM S_TYPE_INTERNAL S_TYPE_INTERNALSOLID S_TYPE_INTERNALBRIDGE S_TYPE_INTERNALVOID);
  7. our %EXPORT_TAGS = (types => \@EXPORT_OK);
  8. # static method to group surfaces having same surface_type, bridge_angle and thickness*
  9. sub group {
  10. my $class = shift;
  11. my $params = ref $_[0] eq 'HASH' ? shift(@_) : {};
  12. my (@surfaces) = @_;
  13. my %unique_types = ();
  14. foreach my $surface (@surfaces) {
  15. my $type = join '_',
  16. ($params->{merge_solid} && $surface->is_solid) ? 'solid' : $surface->surface_type,
  17. $surface->bridge_angle // '',
  18. $surface->thickness // '',
  19. $surface->thickness_layers;
  20. $unique_types{$type} ||= [];
  21. push @{ $unique_types{$type} }, $surface;
  22. }
  23. return values %unique_types;
  24. }
  25. sub offset {
  26. my $self = shift;
  27. return [ map $self->clone(expolygon => $_), @{$self->expolygon->offset_ex(@_)} ];
  28. }
  29. sub p {
  30. my $self = shift;
  31. return @{$self->polygons};
  32. }
  33. 1;