<commit_before>﻿/*
This file is part of MatterSlice. A command line utility for
generating 3D printing GCode.

Copyright (C) 2013 <NAME>
Copyright (c) 2014, <NAME>

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

This program 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 Affero General Public License for more details.

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

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using MatterHackers.VectorMath;
using MSClipperLib;

namespace MatterHackers.MatterSlice
{
	public class ConfigConstants
	{
		public const int MAX_EXTRUDERS = 4;
		public const string VERSION = "1.0";

		public enum INFILL_TYPE
		{
			GRID,
			LINES,
			TRIANGLES,
			HEXAGON,
			CONCENTRIC,
		}

		/**
		 * * Type of support material.
		 * * Grid is a X/Y grid with an outline, which is very strong, provides good support. But in some cases is hard to remove.
		 * * Lines give a row of lines which break off one at a time, making them easier to remove, but they do not support as good as the grid support.
		 * */

		public enum SUPPORT_TYPE
		{
			GRID,
			LINES
		}
	}

	// all the variables in this class will be saved and loaded from settings files
	public class ConfigSettings
	{
		// Store all public instance properties in a local static list to resolve settings mappings
		private static List<PropertyInfo> allProperties = typeof(ConfigSettings).GetProperties(BindingFlags.Public | BindingFlags.Instance).ToList();

		private int extruderCount = 0;

		public ConfigSettings()
		{
			SetToDefault();
		}

		[SettingDescription("Avoid crossing any of the perimeters of a shape while printing its parts.")]
		public bool AvoidCrossingPerimeters { get; set; }

		public string BeforeToolchangeCode { get; set; }

		public string BooleanOperations { get; set; } = "";

		[SettingDescription("This is the speed to print the bottom layers infill, mm/s.")]
		public double BottomInfillSpeed { get; set; }

		[SettingDescription("The speed to run the fan during bridging.")]
		public int BridgeFanSpeedPercent { get; set; }

		[SettingDescription("mm/s.")]
		public int BridgeSpeed { get; set; }

		// other
		[SettingDescription("This will cause the z height to raise continuously while on the outer perimeter.")]
		public bool ContinuousSpiralOuterPerimeter { get; set; }

		// Raft settings
		[SettingDescription("mm.")]
		public bool EnableRaft { get; set; }

		public string EndCode { get; set; }

		[SettingDescription("Detect and output walls than are less than the nozzle diameter. Output width will be nozzle diameter.")]
		public bool ExpandThinWalls { get; set; } = false;

		public IntPoint[] ExtruderOffsets { get; set; } = new IntPoint[ConfigConstants.MAX_EXTRUDERS];

		[SettingDescription("Lets you adjust how much material to extrude.")]
		public double ExtrusionMultiplier { get; set; }

		[SettingDescription("The width of the line to extrude.")]
		public double ExtrusionWidth { get; set; }

		public int ExtrusionWidth_um => (int)(ExtrusionWidth * 1000);
		public int FanSpeedMaxPercent { get; set; }
		public int FanSpeedMinPercent { get; set; }

		[SettingDescription("The width of the filament being fed into the extruder, in millimeters.")]
		public double FilamentDiameter { get; set; }

		public int FilamentDiameter_um => (int)(FilamentDiameter * 1000);

		[SettingDescription("If set thin gaps between perimeter lines will be filled.")]
		public bool FillThinGaps { get; set; } = false;

		[SettingDescription("The width of the line to extrude for the first layer.")]
		public double FirstLayerExtrusionWidth { get; set; }

		public int FirstLayerExtrusionWidth_um => (int)(FirstLayerExtrusionWidth * 1000);

		// speed settings
		[SettingDescription("This is the speed to print everything on the first layer, mm/s.")]
		public double FirstLayerSpeed { get; set; }

		public int NumberOfFirstLayers { get; set; }

		[SettingDescription("The height of the first layer to print, in millimeters.")]
		public double FirstLayerThickness { get; set; }

		public int FirstLayerThickness_um => (int)(FirstLayerThickness * 1000);

		[SettingDescription("The fan will be force to stay off below this layer.")]
		public int FirstLayerToAllowFan { get; set; }

		[SettingDescription("If True, support will be generated within the part as well as from the bed.")]
		public bool GenerateInternalSupport { get; set; }

		[SettingDescription("If True, support will be generated from the bed. If false no support will be generated at all.")]
		public bool GenerateSupport { get; set; }

		[SettingDescription("If True, an external perimeter will be created around each support island.")]
		public bool GenerateSupportPerimeter { get; set; }

		[SettingDescription("The amount the infill extends into the perimeter in millimeters.")]
		public double InfillExtendIntoPerimeter { get; set; }

		public int InfillExtendIntoPerimeter_um => (int)(InfillExtendIntoPerimeter * 1000);

		[SettingDescription("The percent of filled space to open space while infilling.")]
		public double InfillPercent { get; set; }

		[SettingDescription("mm/s.")]
		public int InfillSpeed { get; set; }

		[SettingDescription("The starting angle that infill lines will be drawn at (angle in x y).")]
		public double InfillStartingAngle { get; set; } = 45;

		public ConfigConstants.INFILL_TYPE InfillType { get; set; }

		[SettingDescription("The speed of all perimeters but the outside one. mm/s.")]
		public int InsidePerimetersSpeed { get; set; }

		public string LayerChangeCode { get; set; } = "; LAYER:[layer_num]";

		// if you were to change the layerThicknessMm variable you would add a legacy name so that we can still use old settings
		//[LegacyName("layerThickness")] // the name before we added Mm
		public double LayerThickness { get; set; }

		public int LayerThickness_um => (int)(LayerThickness * 1000);
		public bool MergeOverlappingLines { get; set; } = true;

		[SettingDescription("mm.")]
		public double MinimumExtrusionBeforeRetraction { get; set; }

		//Cool settings
		public int MinimumLayerTimeSeconds { get; set; }

		[SettingDescription("The minimum speed that the extruder is allowed to move while printing. mm/s.")]
		public int MinimumPrintingSpeed { get; set; }

		[SettingDescription("The minimum travel distance that will require a retraction")]
		public double MinimumTravelToCauseRetraction { get; set; }

		public int MinimumTravelToCauseRetraction_um => (int)(MinimumTravelToCauseRetraction * 1000);

		// object transform
		public Matrix4X4 ModelMatrix { get; set; } = new Matrix4X4();

		public int MultiExtruderOverlapPercent { get; set; }
		public int NumberOfBottomLayers { get; set; }

		[SettingDescription("The number of loops to draw around islands.")]
		public int NumberOfBrimLoops { get; set; }

		public int NumberOfPerimeters { get; set; }

		[SettingDescription("The number of loops to draw around the convex hull")]
		public int NumberOfSkirtLoops { get; set; }

		public int NumberOfTopLayers { get; set; }<commit_msg>Need identity for default<commit_after>﻿/*
This file is part of MatterSlice. A command line utility for
generating 3D printing GCode.

Copyright (C) 2013 <NAME>
Copyright (c) 2014, <NAME>

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

This program 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 Affero General Public License for more details.

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

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using MatterHackers.VectorMath;
using MSClipperLib;

namespace MatterHackers.MatterSlice
{
	public class ConfigConstants
	{
		public const int MAX_EXTRUDERS = 4;
		public const string VERSION = "1.0";

		public enum INFILL_TYPE
		{
			GRID,
			LINES,
			TRIANGLES,
			HEXAGON,
			CONCENTRIC,
		}

		/**
		 * * Type of support material.
		 * * Grid is a X/Y grid with an outline, which is very strong, provides good support. But in some cases is hard to remove.
		 * * Lines give a row of lines which break off one at a time, making them easier to remove, but they do not support as good as the grid support.
		 * */

		public enum SUPPORT_TYPE
		{
			GRID,
			LINES
		}
	}

	// all the variables in this class will be saved and loaded from settings files
	public class ConfigSettings
	{
		// Store all public instance properties in a local static list to resolve settings mappings
		private static List<PropertyInfo> allProperties = typeof(ConfigSettings).GetProperties(BindingFlags.Public | BindingFlags.Instance).ToList();

		private int extruderCount = 0;

		public ConfigSettings()
		{
			SetToDefault();
		}

		[SettingDescription("Avoid crossing any of the perimeters of a shape while printing its parts.")]
		public bool AvoidCrossingPerimeters { get; set; }

		public string BeforeToolchangeCode { get; set; }

		public string BooleanOperations { get; set; } = "";

		[SettingDescription("This is the speed to print the bottom layers infill, mm/s.")]
		public double BottomInfillSpeed { get; set; }

		[SettingDescription("The speed to run the fan during bridging.")]
		public int BridgeFanSpeedPercent { get; set; }

		[SettingDescription("mm/s.")]
		public int BridgeSpeed { get; set; }

		// other
		[SettingDescription("This will cause the z height to raise continuously while on the outer perimeter.")]
		public bool ContinuousSpiralOuterPerimeter { get; set; }

		// Raft settings
		[SettingDescription("mm.")]
		public bool EnableRaft { get; set; }

		public string EndCode { get; set; }

		[SettingDescription("Detect and output walls than are less than the nozzle diameter. Output width will be nozzle diameter.")]
		public bool ExpandThinWalls { get; set; } = false;

		public IntPoint[] ExtruderOffsets { get; set; } = new IntPoint[ConfigConstants.MAX_EXTRUDERS];

		[SettingDescription("Lets you adjust how much material to extrude.")]
		public double ExtrusionMultiplier { get; set; }

		[SettingDescription("The width of the line to extrude.")]
		public double ExtrusionWidth { get; set; }

		public int ExtrusionWidth_um => (int)(ExtrusionWidth * 1000);
		public int FanSpeedMaxPercent { get; set; }
		public int FanSpeedMinPercent { get; set; }

		[SettingDescription("The width of the filament being fed into the extruder, in millimeters.")]
		public double FilamentDiameter { get; set; }

		public int FilamentDiameter_um => (int)(FilamentDiameter * 1000);

		[SettingDescription("If set thin gaps between perimeter lines will be filled.")]
		public bool FillThinGaps { get; set; } = false;

		[SettingDescription("The width of the line to extrude for the first layer.")]
		public double FirstLayerExtrusionWidth { get; set; }

		public int FirstLayerExtrusionWidth_um => (int)(FirstLayerExtrusionWidth * 1000);

		// speed settings
		[SettingDescription("This is the speed to print everything on the first layer, mm/s.")]
		public double FirstLayerSpeed { get; set; }

		public int NumberOfFirstLayers { get; set; }

		[SettingDescription("The height of the first layer to print, in millimeters.")]
		public double FirstLayerThickness { get; set; }

		public int FirstLayerThickness_um => (int)(FirstLayerThickness * 1000);

		[SettingDescription("The fan will be force to stay off below this layer.")]
		public int FirstLayerToAllowFan { get; set; }

		[SettingDescription("If True, support will be generated within the part as well as from the bed.")]
		public bool GenerateInternalSupport { get; set; }

		[SettingDescription("If True, support will be generated from the bed. If false no support will be generated at all.")]
		public bool GenerateSupport { get; set; }

		[SettingDescription("If True, an external perimeter will be created around each support island.")]
		public bool GenerateSupportPerimeter { get; set; }

		[SettingDescription("The amount the infill extends into the perimeter in millimeters.")]
		public double InfillExtendIntoPerimeter { get; set; }

		public int InfillExtendIntoPerimeter_um => (int)(InfillExtendIntoPerimeter * 1000);

		[SettingDescription("The percent of filled space to open space while infilling.")]
		public double InfillPercent { get; set; }

		[SettingDescription("mm/s.")]
		public int InfillSpeed { get; set; }

		[SettingDescription("The starting angle that infill lines will be drawn at (angle in x y).")]
		public double InfillStartingAngle { get; set; } = 45;

		public ConfigConstants.INFILL_TYPE InfillType { get; set; }

		[SettingDescription("The speed of all perimeters but the outside one. mm/s.")]
		public int InsidePerimetersSpeed { get; set; }

		public string LayerChangeCode { get; set; } = "; LAYER:[layer_num]";

		// if you were to change the layerThicknessMm variable you would add a legacy name so that we can still use old settings
		//[LegacyName("layerThickness")] // the name before we added Mm
		public double LayerThickness { get; set; }

		public int LayerThickness_um => (int)(LayerThickness * 1000);
		public bool MergeOverlappingLines { get; set; } = true;

		[SettingDescription("mm.")]
		public double MinimumExtrusionBeforeRetraction { get; set; }

		//Cool settings
		public int MinimumLayerTimeSeconds { get; set; }

		[SettingDescription("The minimum speed that the extruder is allowed to move while printing. mm/s.")]
		public int MinimumPrintingSpeed { get; set; }

		[SettingDescription("The minimum travel distance that will require a retraction")]
		public double MinimumTravelToCauseRetraction { get; set; }

		public int MinimumTravelToCauseRetraction_um => (int)(MinimumTravelToCauseRetraction * 1000);

		// object transform
		public Matrix4X4 ModelMatrix { get; set; } = Matrix4X4.Identity;

		public int MultiExtruderOverlapPercent { get; set; }
		public int NumberOfBottomLayers { get; set; }

		[SettingDescription("The number of loops to draw around islands.")]
		public int NumberOfBrimLoops { get; set; }

		public int NumberOfPerimeters { get; set; }

		[SettingDescription("The number of loops to draw around the convex hull")]
		public int NumberOfSkirtLoops { get; set; }

		public int NumberOfTopLayers { get; set; }
{'fraction_non_alphanumeric': 0.08401844796470824, 'fraction_numerical': 0.006416683376779627, 'mean_word_length': 4.343571428571429, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, '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': '7440069', 'n_tokens_mistral': 4661, 'n_tokens_neox': 4076, 'n_words': 1704}