<commit_before>//Copyright (c) 2020 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.

#include <cassert>

#include "LimitedBeadingStrategy.h"

namespace cura
{

LimitedBeadingStrategy::Beading LimitedBeadingStrategy::compute(coord_t thickness, coord_t bead_count) const
{
    if (bead_count <= max_bead_count)
    {
        return parent->compute(thickness, bead_count);
    }
    assert(bead_count == max_bead_count + 1);

    coord_t optimal_thickness = parent->getOptimalThickness(max_bead_count);
    Beading ret = parent->compute(optimal_thickness, max_bead_count);
    ret.left_over += thickness - ret.total_thickness;
    ret.total_thickness = thickness;
    
    // Enforce symmetry
    if (bead_count % 2 == 1)
    {<commit_msg>Workaround: add a 0-width wall in locations where there are maximum walls<commit_after>//Copyright (c) 2020 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.

#include <cassert>

#include "LimitedBeadingStrategy.h"

namespace cura
{

LimitedBeadingStrategy::Beading LimitedBeadingStrategy::compute(coord_t thickness, coord_t bead_count) const
{
    if (bead_count <= max_bead_count)
    {
        Beading ret = parent->compute(thickness, bead_count);

        if (bead_count % 2 == 0 && bead_count == max_bead_count)
        {
            const coord_t innermost_toolpath_location = ret.toolpath_locations[max_bead_count / 2 - 1];
            const coord_t innermost_toolpath_width = ret.bead_widths[max_bead_count / 2 - 1];
            ret.toolpath_locations.insert(ret.toolpath_locations.begin() + max_bead_count / 2, innermost_toolpath_location + innermost_toolpath_width / 2);
            ret.bead_widths.insert(ret.bead_widths.begin() + max_bead_count / 2, 0);
        }
        return ret;
    }
    assert(bead_count == max_bead_count + 1);

    coord_t optimal_thickness = parent->getOptimalThickness(max_bead_count);
    Beading ret = parent->compute(optimal_thickness, max_bead_count);
    ret.left_over += thickness - ret.total_thickness;
    ret.total_thickness = thickness;
    
    // Enforce symmetry
    if (bead_count % 2 == 1)
    {
{'fraction_non_alphanumeric': 0.09627906976744185, 'fraction_numerical': 0.012558139534883722, 'mean_word_length': 3.6862745098039214, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '362570', 'n_tokens_mistral': 772, 'n_tokens_neox': 717, 'n_words': 152}