LineIdentified.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using o0.Geometry2D.Float;
  2. namespace o0.Project
  3. {
  4. public class LineIdentified
  5. {
  6. // 属于的识别批次
  7. public int Batch;
  8. // 线段
  9. public Line Line;
  10. // 线梯度
  11. public float Gradient;
  12. // 线梯度方向, 0 - 180度
  13. public float GradientDegree;
  14. // 筛线条时, 计算垂直直线的梯度值
  15. public float ZIMGradient;
  16. // 到屏幕中点的距离
  17. public float DistanceToMiddle;
  18. // 用于绘制的线, 为null就是不绘制
  19. public Line DrawLine;
  20. // 被认为是屏幕的哪条边,-1表示不是屏幕的边,0, 1, 2,3对应 下、右、上、左
  21. public int ScreenLineIndex;
  22. public LineIdentified(int batch, Line line, float gradient, float gradientDegree, bool drawAll = false)
  23. {
  24. Batch = batch;
  25. Line = line;
  26. Gradient = gradient;
  27. GradientDegree = gradientDegree;
  28. if (drawAll)
  29. DrawLine = line;
  30. }
  31. public LineIdentified(int batch, (Line line, float gradient, float gradientDegree) lineParams, bool drawAll = false)
  32. {
  33. Batch = batch;
  34. Line = lineParams.line;
  35. Gradient = lineParams.gradient;
  36. GradientDegree = lineParams.gradientDegree;
  37. if (drawAll)
  38. DrawLine = lineParams.line;
  39. }
  40. bool? _isInterLine;
  41. // 评估是否是屏幕内部的线
  42. public bool GuessIsInterLine(InterLineGuess guess)
  43. {
  44. if (_isInterLine == null)
  45. _isInterLine = guess.GuessIsLine(this);
  46. return _isInterLine.Value;
  47. }
  48. public void Offset(Vector offset)
  49. {
  50. Line += offset;
  51. }
  52. }
  53. }