Browse Source

Make angle increment (i.e. angle resolution) configurable

Alessandro Ranellucci 11 years ago
parent
commit
627f23d5fe
2 changed files with 3 additions and 3 deletions
  1. 2 2
      lib/Slic3r/Layer/BridgeDetector.pm
  2. 1 1
      t/bridges.t

+ 2 - 2
lib/Slic3r/Layer/BridgeDetector.pm

@@ -8,6 +8,7 @@ use Slic3r::Geometry::Clipper qw(intersection_pl intersection_ex);
 has 'lower_slices'      => (is => 'rw', required => 1);  # ExPolygons or ExPolygonCollection
 has 'perimeter_flow'    => (is => 'rw', required => 1);
 has 'infill_flow'       => (is => 'rw', required => 1);
+has 'resolution' =>     => (is => 'rw', default => sub { PI/36 });
 
 sub detect_angle {
     my ($self, $expolygon) = @_;
@@ -69,9 +70,8 @@ sub detect_angle {
             # bridge in several directions and then sum the length of lines having both
             # endpoints within anchors
             my %directions = ();  # angle => score
-            my $angle_increment = PI/36; # 5°
             my $line_increment = $self->infill_flow->scaled_width;
-            for (my $angle = 0; $angle < PI; $angle += $angle_increment) {
+            for (my $angle = 0; $angle < PI; $angle += $self->resolution) {
                 my $my_inset   = [ map $_->clone, @$inset ];
                 my $my_anchors = [ map $_->clone, @$anchors ];
                 

+ 1 - 1
t/bridges.t

@@ -79,7 +79,7 @@ sub check_angle {
     
     # our epsilon is equal to the steps used by the bridge detection algorithm
     ###use XXX; YYY [ rad2deg($result), $expected ];
-    return defined $result && abs(rad2deg($result) - $expected) < rad2deg(PI/36);
+    return defined $result && abs(rad2deg($result) - $expected) < rad2deg($bd->resolution);
 }
 
 __END__