using PaintDotNet.Base.DedicatedAnalysis.Inclusions.Model; using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using static PaintDotNet.Base.DedicatedAnalysis.Inclusions.InclusionsGlobalSettings; namespace PaintDotNet.Base.DedicatedAnalysis.Inclusions.Standard.DIN50602_1985 { public class DIN50602_1985 : InclusionsStandard { public DIN50602_1985(double pxPerUnit) { this.globalSettings.binaryThreshold = 175; this.globalSettings.pxPerUnit = pxPerUnit; this.globalSettings.distancesBetweenParticlesE = 40; this.globalSettings.distancesBetweenParticlesT = 10; this.globalSettings.distancesBetweenStringersE = 40; this.globalSettings.distancesBetweenStringersT = 10; this.globalSettings.minimumLength = 3; this.globalSettings.minimumWidth = 2; this.globalSettings.lwRatioLimit = 3f; string[] types = { "SS", "OA", "OS", "OG"}; for (int i = 0; i < types.Length; i++) { TypesOfInclusions typesOfInclusion = new TypesOfInclusions(types[i]); typesOfInclusion.showColor = InclusionsStandard.RAINBOW_COLORS[i].ToArgb(); this.globalSettings.typeDics.Add(types[i], typesOfInclusion); } this.globalSettings.colorOfInclusions.Add("Black", new ColorOfInclusions("Black", new TypesOfInclusions[] { this.globalSettings.typeDics["SS"] }, Color.Black)); this.globalSettings.colorOfInclusions.Add("Gray", new ColorOfInclusions("Gray", new TypesOfInclusions[] { this.globalSettings.typeDics["OA"] }, Color.DarkGray)); this.globalSettings.colorOfInclusions.Add("DarkGray", new ColorOfInclusions("DarkGray", new TypesOfInclusions[] { this.globalSettings.typeDics["OS"] }, Color.Gray)); this.globalSettings.colorOfInclusions.Add("LightBlue", new ColorOfInclusions("LightBlue", new TypesOfInclusions[] { this.globalSettings.typeDics["OG"] }, Color.LightBlue)); } public override void edgeErrorsCorrection(List inclusions) { throw new NotImplementedException(); } public override void determineType(Inclusion inclusion) { Dictionary typeCount = new Dictionary(); foreach (var type in this.globalSettings.typeDics) { typeCount.Add(type.Value, 0); } switch (inclusion.classes) { case ClassesOfInclusions.α: typeCount[this.globalSettings.typeDics["SS"]] = typeCount[this.globalSettings.typeDics["SS"]] + 2; typeCount[this.globalSettings.typeDics["OA"]] = typeCount[this.globalSettings.typeDics["OA"]] + 2; break; case ClassesOfInclusions.β: typeCount[this.globalSettings.typeDics["OA"]] = typeCount[this.globalSettings.typeDics["OA"]] + 2; break; case ClassesOfInclusions.γ: typeCount[this.globalSettings.typeDics["OS"]] = typeCount[this.globalSettings.typeDics["OS"]] + 2; break; case ClassesOfInclusions.δ: typeCount[this.globalSettings.typeDics["OG"]] = typeCount[this.globalSettings.typeDics["OG"]] + 2; break; } if (inclusion.color != null) { foreach (TypesOfInclusions item in inclusion.color.ofTypes) { typeCount[this.globalSettings.typeDics[item.type]]++; } } inclusion.type = typeCount.First(r => r.Value == typeCount.Max(t => t.Value)).Key; } } }