<commit_before>package Slic3r::Fill::Rectilinear;
use Moo;

extends 'Slic3r::Fill::Base';

use Slic3r::Geometry qw(X1 Y1 X2 Y2 A B X Y scale unscale epsilon);
use XXX;

sub fill_surface {
    my $self = shift;
    my ($surface, %params) = @_;
    
    # rotate polygons so that we can work with vertical lines here
    my $expolygon = $surface->expolygon;
    my $rotate_vector = $self->infill_direction($surface);
    $self->rotate_points($expolygon, $rotate_vector);
    
    my $bounding_box = [ $expolygon->bounding_box ];
    $bounding_box->[X1] += scale 0.1;
    $bounding_box->[X2] -= scale 0.1;
    
    my $min_spacing = scale $params{flow_spacing};
    my $distance_between_lines = $min_spacing / $params{density};
    my $line_oscillation = $distance_between_lines - $min_spacing;
    
    my $flow_spacing;
    if ($params{density} == 1) {
        $distance_between_lines = $self->adjust_solid_spacing(
            width       => $bounding_box->[X2] - $bounding_box->[X1],
            distance    => $distance_between_lines,
        );
        $flow_spacing = unscale $distance_between_lines;
    }
    
    my $overlap_distance = $Slic3r::nozzle_diameter * 0.20;
    
    my @paths = ();
    my $x = $bounding_box->[X1];
    my $is_line_pattern = $self->isa('Slic3r::Fill::Line');
    for (my $i = 0; $x <= $bounding_box->[X2] + scale epsilon; $i++) {
        my $vertical_line = [ [$x, $bounding_box->[Y2]], [$x, $bounding_box->[Y1]] ];
        if ($is_line_pattern && $i % 2) {
            $vertical_line->[A][X] -= $line_oscillation;
            $vertical_line->[B][X] += $line_oscillation;
        }
        my @clipped_lines = @{ $expolygon->clip_line($vertical_line) };
        for (@clipped_lines) {
            $_->[0][Y] += $overlap_distance;
            $_->[-1][Y] -= $overlap_distance;
        }
        push @paths, @clipped_lines;
        $x += $distance_between_lines;
    }
    
    # connect lines
    {<commit_msg>Poor overlap between perimeters and infill<commit_after>package Slic3r::Fill::Rectilinear;
use Moo;

extends 'Slic3r::Fill::Base';

use Slic3r::Geometry qw(X1 Y1 X2 Y2 A B X Y scale unscale epsilon);
use XXX;

sub fill_surface {
    my $self = shift;
    my ($surface, %params) = @_;
    
    # rotate polygons so that we can work with vertical lines here
    my $expolygon = $surface->expolygon;
    my $rotate_vector = $self->infill_direction($surface);
    $self->rotate_points($expolygon, $rotate_vector);
    
    my $bounding_box = [ $expolygon->bounding_box ];
    $bounding_box->[X1] += scale 0.1;
    $bounding_box->[X2] -= scale 0.1;
    
    my $min_spacing = scale $params{flow_spacing};
    my $distance_between_lines = $min_spacing / $params{density};
    my $line_oscillation = $distance_between_lines - $min_spacing;
    
    my $flow_spacing;
    if ($params{density} == 1) {
        $distance_between_lines = $self->adjust_solid_spacing(
            width       => $bounding_box->[X2] - $bounding_box->[X1],
            distance    => $distance_between_lines,
        );
        $flow_spacing = unscale $distance_between_lines;
    }
    
    my $overlap_distance = scale $Slic3r::flow_width * 0.2;
    
    my @paths = ();
    my $x = $bounding_box->[X1];
    my $is_line_pattern = $self->isa('Slic3r::Fill::Line');
    for (my $i = 0; $x <= $bounding_box->[X2] + scale epsilon; $i++) {
        my $vertical_line = [ [$x, $bounding_box->[Y2]], [$x, $bounding_box->[Y1]] ];
        if ($is_line_pattern && $i % 2) {
            $vertical_line->[A][X] -= $line_oscillation;
            $vertical_line->[B][X] += $line_oscillation;
        }
        my @clipped_lines = @{ $expolygon->clip_line($vertical_line) };
        for (@clipped_lines) {
            $_->[0][Y] += $overlap_distance;
            $_->[-1][Y] -= $overlap_distance;
        }
        push @paths, @clipped_lines;
        $x += $distance_between_lines;
    }
    
    # connect lines
    {
{'fraction_non_alphanumeric': 0.15667262056647105, 'fraction_numerical': 0.014544526664965552, 'mean_word_length': 2.7583892617449663, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '752471', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1390, 'n_words': 276}