GBT10561_2005.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.GBT10561_2005
  10. {
  11. public class GBT10561_2005 : InclusionsStandard
  12. {
  13. public GBT10561_2005(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 = { "A", "B", "C", "D", "DS" };
  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["B"], this.globalSettings.typeDics["C"], this.globalSettings.typeDics["D"] },Color.Black));
  32. this.globalSettings.colorOfInclusions.Add("Gray", new ColorOfInclusions("Gray", new TypesOfInclusions[] { this.globalSettings.typeDics["A"] }, Color.DarkGray));
  33. this.globalSettings.colorOfInclusions.Add("DarkGray", new ColorOfInclusions("DarkGray", new TypesOfInclusions[] { this.globalSettings.typeDics["C"] }, Color.Gray));
  34. this.globalSettings.colorOfInclusions.Add("LightBlue", new ColorOfInclusions("LightBlue", new TypesOfInclusions[] { this.globalSettings.typeDics["B"], this.globalSettings.typeDics["D"] }, Color.LightBlue));
  35. }
  36. public override void determineType(Inclusion inclusion)
  37. {
  38. Dictionary<TypesOfInclusions, int> typeCount = new Dictionary<TypesOfInclusions, int>();
  39. foreach (var type in this.globalSettings.typeDics)
  40. {
  41. typeCount.Add(type.Value, 0);
  42. }
  43. switch (inclusion.classes)
  44. {
  45. case ClassesOfInclusions.α:
  46. typeCount[this.globalSettings.typeDics["A"]] = typeCount[this.globalSettings.typeDics["A"]] + 2;
  47. typeCount[this.globalSettings.typeDics["C"]] = typeCount[this.globalSettings.typeDics["C"]] + 2;
  48. break;
  49. case ClassesOfInclusions.β:
  50. typeCount[this.globalSettings.typeDics["B"]] = typeCount[this.globalSettings.typeDics["B"]] + 2;
  51. break;
  52. case ClassesOfInclusions.γ:
  53. typeCount[this.globalSettings.typeDics["A"]] = typeCount[this.globalSettings.typeDics["A"]] + 2;
  54. typeCount[this.globalSettings.typeDics["C"]] = typeCount[this.globalSettings.typeDics["C"]] + 2;
  55. break;
  56. case ClassesOfInclusions.δ:
  57. if (inclusion.physicalWidth >= 13)
  58. {
  59. typeCount[this.globalSettings.typeDics["DS"]] = typeCount[this.globalSettings.typeDics["DS"]] + 2;
  60. }
  61. else
  62. {
  63. typeCount[this.globalSettings.typeDics["D"]] = typeCount[this.globalSettings.typeDics["D"]] + 2;
  64. }
  65. break;
  66. }
  67. if (inclusion.color != null)
  68. {
  69. foreach (TypesOfInclusions item in inclusion.color.ofTypes)
  70. {
  71. typeCount[this.globalSettings.typeDics[item.type]]++;
  72. }
  73. }
  74. inclusion.type = typeCount.First(r => r.Value == typeCount.Max(t => t.Value)).Key;
  75. }
  76. public override void edgeErrorsCorrection(List<Inclusion> inclusions)
  77. {
  78. throw new NotImplementedException();
  79. }
  80. }
  81. }