DIN50602_1985.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using PaintDotNet.Base.DedicatedAnalysis.Inclusions.Model;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using static PaintDotNet.Base.DedicatedAnalysis.Inclusions.InclusionsGlobalSettings;
  9. namespace PaintDotNet.Base.DedicatedAnalysis.Inclusions.Standard.DIN50602_1985
  10. {
  11. public class DIN50602_1985 : InclusionsStandard
  12. {
  13. public DIN50602_1985(double pxPerUnit)
  14. {
  15. this.globalSettings.binaryThreshold = 175;
  16. this.globalSettings.pxPerUnit = pxPerUnit;
  17. this.globalSettings.distancesBetweenParticlesE = 40;
  18. this.globalSettings.distancesBetweenParticlesT = 10;
  19. this.globalSettings.distancesBetweenStringersE = 40;
  20. this.globalSettings.distancesBetweenStringersT = 10;
  21. this.globalSettings.minimumLength = 3;
  22. this.globalSettings.minimumWidth = 2;
  23. this.globalSettings.lwRatioLimit = 3f;
  24. string[] types = { "SS", "OA", "OS", "OG"};
  25. for (int i = 0; i < types.Length; i++)
  26. {
  27. TypesOfInclusions typesOfInclusion = new TypesOfInclusions(types[i]);
  28. typesOfInclusion.showColor = InclusionsStandard.RAINBOW_COLORS[i].ToArgb();
  29. this.globalSettings.typeDics.Add(types[i], typesOfInclusion);
  30. }
  31. this.globalSettings.colorOfInclusions.Add("Black", new ColorOfInclusions("Black", new TypesOfInclusions[] { this.globalSettings.typeDics["SS"] }, Color.Black));
  32. this.globalSettings.colorOfInclusions.Add("Gray", new ColorOfInclusions("Gray", new TypesOfInclusions[] { this.globalSettings.typeDics["OA"] }, Color.DarkGray));
  33. this.globalSettings.colorOfInclusions.Add("DarkGray", new ColorOfInclusions("DarkGray", new TypesOfInclusions[] { this.globalSettings.typeDics["OS"] }, Color.Gray));
  34. this.globalSettings.colorOfInclusions.Add("LightBlue", new ColorOfInclusions("LightBlue", new TypesOfInclusions[] { this.globalSettings.typeDics["OG"] }, Color.LightBlue));
  35. }
  36. public override void edgeErrorsCorrection(List<Inclusion> inclusions)
  37. {
  38. throw new NotImplementedException();
  39. }
  40. public override void determineType(Inclusion inclusion)
  41. {
  42. Dictionary<TypesOfInclusions, int> typeCount = new Dictionary<TypesOfInclusions, int>();
  43. foreach (var type in this.globalSettings.typeDics)
  44. {
  45. typeCount.Add(type.Value, 0);
  46. }
  47. switch (inclusion.classes)
  48. {
  49. case ClassesOfInclusions.α:
  50. typeCount[this.globalSettings.typeDics["SS"]] = typeCount[this.globalSettings.typeDics["SS"]] + 2;
  51. typeCount[this.globalSettings.typeDics["OA"]] = typeCount[this.globalSettings.typeDics["OA"]] + 2;
  52. break;
  53. case ClassesOfInclusions.β:
  54. typeCount[this.globalSettings.typeDics["OA"]] = typeCount[this.globalSettings.typeDics["OA"]] + 2;
  55. break;
  56. case ClassesOfInclusions.γ:
  57. typeCount[this.globalSettings.typeDics["OS"]] = typeCount[this.globalSettings.typeDics["OS"]] + 2;
  58. break;
  59. case ClassesOfInclusions.δ:
  60. typeCount[this.globalSettings.typeDics["OG"]] = typeCount[this.globalSettings.typeDics["OG"]] + 2;
  61. break;
  62. }
  63. if (inclusion.color != null)
  64. {
  65. foreach (TypesOfInclusions item in inclusion.color.ofTypes)
  66. {
  67. typeCount[this.globalSettings.typeDics[item.type]]++;
  68. }
  69. }
  70. inclusion.type = typeCount.First(r => r.Value == typeCount.Max(t => t.Value)).Key;
  71. }
  72. }
  73. }