<commit_before>/*
Copyright (C) 2013 <NAME>
Copyright (c) 2014, <NAME>

This file is part of MatterSlice.

MatterSlice is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

MatterSlice is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with MatterSlice.  If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using System.Collections.Generic;
using System.Diagnostics;

using MatterSlice.ClipperLib;

namespace MatterHackers.MatterSlice
{
    using Polygon = List<IntPoint>;
    using Polygons = List<List<IntPoint>>;

    public static class Inset
    {
        public static void generateInsets(SliceLayerPart part, int offset, int insetCount)
        {
            part.combBoundery = part.outline.Offset(-offset);
            if (insetCount == 0)
            {
                // if we have no insets defined still create one
                part.insets.Add(part.outline);
            }
            else // generate the insets
            {
                for (int i = 0; i < insetCount; i++)
                {
                    part.insets.Add(new Polygons());
                    part.insets[i] = part.outline.Offset(-offset * i - offset / 2);

                    if (i == 0)
                    {
                        // Add thin wall filling by taking the area between the insets.
                        //Polygons thinWalls = part.insets[0].Offset(-offset / 4).CreateDifference(part.insets[0].Offset);
                        //upskin.AddAll(thinWalls);
                        //downskin.AddAll(thinWalls);
                    }

                    long minimumDistanceToCreateNewPosition = 10;
                    part.insets[i] = Clipper.CleanPolygons(part.insets[i], minimumDistanceToCreateNewPosition);

                    if (part.insets[i].Count < 1)
                    {
                        part.insets.RemoveAt(part.insets.Count - 1);
                        break;
                    }
                }
            }
        }

        public static void generateInsets(SliceLayer layer, int offset, int insetCount)
        {
            for (int partNr = 0; partNr < layer.parts.Count; partNr++)
            {
                generateInsets(layer.parts[partNr], offset, insetCount);
            }

            //Remove the parts which did not generate an inset. As these parts are too small to print,
            // and later code can now assume that there is always minimum 1 inset line.
            for (int partIndex = 0; partIndex < layer.parts.Count; partIndex++)
            {
                if (layer.parts[partIndex].insets.Count < 1)
                {
                    layer.parts.RemoveAt(partIndex);
                    partIndex -= 1;
                }
            }
        }
    }
}<commit_msg>Clarity<commit_after>/*
Copyright (C) 2013 <NAME>
Copyright (c) 2014, <NAME>

This file is part of MatterSlice.

MatterSlice is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

MatterSlice is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with MatterSlice.  If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using System.Collections.Generic;
using System.Diagnostics;

using MatterSlice.ClipperLib;

namespace MatterHackers.MatterSlice
{
    using Polygon = List<IntPoint>;
    using Polygons = List<List<IntPoint>>;

    public static class Inset
    {
        public static void GenerateInsets(SliceLayerPart part, int offset, int insetCount)
        {
            part.combBoundery = part.outline.Offset(-offset);
            if (insetCount == 0)
            {
                // if we have no insets defined still create one
                part.insets.Add(part.outline);
            }
            else // generate the insets
            {
                for (int i = 0; i < insetCount; i++)
                {
                    part.insets.Add(new Polygons());
                    part.insets[i] = part.outline.Offset(-offset * i - offset / 2);

                    long minimumDistanceToCreateNewPosition = 10;
                    part.insets[i] = Clipper.CleanPolygons(part.insets[i], minimumDistanceToCreateNewPosition);

                    if (part.insets[i].Count < 1)
                    {
                        part.insets.RemoveAt(part.insets.Count - 1);
                        break;
                    }
                }
            }
        }

        public static void generateInsets(SliceLayer layer, int offset, int insetCount)
        {
            for (int partIndex = 0; partIndex < layer.parts.Count; partIndex++)
            {
                GenerateInsets(layer.parts[partIndex], offset, insetCount);
            }

            //Remove the parts which did not generate an inset. As these parts are too small to print,
            // and later code can now assume that there is always minimum 1 inset line.
            for (int partIndex = 0; partIndex < layer.parts.Count; partIndex++)
            {
                if (layer.parts[partIndex].insets.Count < 1)
                {
                    layer.parts.RemoveAt(partIndex);
                    partIndex -= 1;
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.08034817542684969, 'fraction_numerical': 0.0077000334784064275, 'mean_word_length': 1.7283105022831051, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5404039', 'n_tokens_mistral': 1624, 'n_tokens_neox': 1494, 'n_words': 518}