Skip to content

allow_overlap no longer adds the final overlapping swath (regression since v2.0.0) #266

Backlog

Description

@u33549

Summary

SwathGeneratorBase::setAllowOverlap(true) has no effect in v2: the same swaths come back with it on or off, and the strip left after the last swath (narrower than half the operation width) is never covered. In v1.2.1 the option added one last swath flush with the far border to cover that strip.

Seen on v2.1.1; the same code is on main and develop (7da703a).

Reproduce

F2CCell rect(F2CLinearRing({{0, 0}, {10, 0}, {10, 3}, {0, 3}, {0, 0}}));
f2c::sg::BruteForce sg;
sg.setAllowOverlap(overlap);
F2CSwaths swaths = sg.generateSwaths(0.0, 0.7, rect);
allow_overlap=0: 4 swaths, y = 0.35 1.05 1.75 2.45
allow_overlap=1: 4 swaths, y = 0.35 1.05 1.75 2.45

The last swath covers up to y = 2.8, so 0.2 m along the top border is never under the tool. With allow_overlap I would expect a fifth swath at y = 2.65.

Cause

src/fields2cover/swath_generator/swath_generator_base.cpp:

double curve_y {-0.5 * op_width};
while (field_height > curve_y + (allow_overlap ? 0.0 : 0.5 * op_width)) {
  curve_y += op_width;
  ...
}

With allow_overlap the loop only runs once more, and that extra centre line is the previous one plus op_width, which is above field_height, outside the field. swaths.append clips it away, so the result does not change.

v1.2.1 (swath_generator_base_impl.hpp, added in 8b98c95 / b90dda3) placed the extra swath at field_width - op_width / 2 when the remainder was under half the width. That step was lost when the generator was rewritten in 0335ee9.

Suggested fix

After the loop, when allow_overlap is set and the last swath's far edge is still below field_height, add one swath centred at field_height - 0.5 * op_width.

Activity

  1. Gonzalo-Mier commented on Dec 1, 2026

    @Gonzalo-Mier
    Member

    In v3 there are different options for this. Can you check them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions