RedrawLine.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. namespace SketchAssistantWPF
  9. {
  10. public class RedrawLine
  11. {
  12. InternalLine LineToRedraw;
  13. Point[] points;
  14. private int radius;
  15. private HashSet<Point>[] detectionZones;
  16. /// <summary>
  17. /// Constructor of the RedrawLine.
  18. /// </summary>
  19. /// <param name="rad">The radius around each point of the line input will be accepted.</param>
  20. public RedrawLine(int rad)
  21. {
  22. radius = rad;
  23. }
  24. /// <summary>
  25. /// A function to intialize the redraw line.
  26. /// </summary>
  27. /// <param name="line"></param>
  28. /// <returns></returns>
  29. public bool Init(InternalLine line)
  30. {
  31. HashSet<Point> initialZone = GeometryCalculator.FilledCircleAlgorithm(new Point(0, 0), radius);
  32. LineToRedraw = line;
  33. points = line.GetPoints().ToArray();
  34. List<HashSet<Point>> dZones = new List<HashSet<Point>>();
  35. foreach(Point p in points)
  36. {
  37. HashSet<Point> newZone = new HashSet<Point>();
  38. foreach(Point i_p in initialZone)
  39. {
  40. newZone.Add(new Point(i_p.X + p.X, i_p.Y + p.Y));
  41. }
  42. dZones.Add(newZone);
  43. }
  44. detectionZones = dZones.ToArray();
  45. Console.WriteLine("This line has {0} points ", line.GetPoints().Count());
  46. return false;
  47. }
  48. public Point GetOverlayPosition()
  49. {
  50. return points[0];
  51. }
  52. public Angle GetDirection(Point p)
  53. {
  54. //TODO: Calculate angles between p and the next n points of the line
  55. // Take average and return it.
  56. return null;
  57. }
  58. }
  59. }