public static List<Point2d> Точки_плотного_размещения(VD<Circle, DeloneCircle> vd, Circle data) { List<Point2d> points = new List<Point2d>(); Triple<Circle, DeloneCircle> triple = vd.NextTriple(vd.NullTriple); while (triple != vd.NullTriple) { points.AddRange(Точки_плотного_размещения(triple, data)); triple = vd.NextTriple(triple); } return points; }
public static Triple<Circle, DeloneCircle> Минимальновозможная_тройка(VD<Circle, DeloneCircle> vd, Circle data) { Triple<Circle, DeloneCircle> temp_triple = vd.NextTriple(vd.NullTriple); while (temp_triple.Delone_Circle.R < data.R) temp_triple = vd.NextTriple(temp_triple); Triple<Circle, DeloneCircle> minimal_triple = temp_triple; while (temp_triple != vd.NullTriple) { if (minimal_triple.Delone_Circle.R > temp_triple.Delone_Circle.R && temp_triple.Delone_Circle.R > data.R) minimal_triple = temp_triple; temp_triple = vd.NextTriple(temp_triple); } return minimal_triple; }
public MainWindow() { InitializeComponent(); this.vd = new VD<Circle, DeloneCircle>(new Circle() { R = 100, X = 150, Y = 200 }, null, new Circle() { R = 50, X = 300, Y = 300 }); GeometryGroup gg = gVD as GeometryGroup; gg.Children.Add(new EllipseGeometry(new System.Windows.Point(300, 300), 50, 50)); gg.Children.Add(new EllipseGeometry(new System.Windows.Point(150, 200), 100, 100)); CreateDeloneCirclesGeometric(); this.vertex = vd.NextTriple(vd.NullTriple).Vertex; }
private void OpenCommand_Execute(object sender, ExecutedRoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == true) { ellipses.Clear(); StreamReader sr = new StreamReader(ofd.FileName); while (!sr.EndOfStream) { String[] g = sr.ReadLine().Split(' '); Circle circle = new Circle() { R = double.Parse(g[0]), X = double.Parse(g[1]), Y = double.Parse(g[2]) }; ellipses.Add(circle); } sr.Close(); vd = new VD<Circle, DeloneCircle>(ellipses[0], ellipses[1], null); for (int i = 2; i < ellipses.Count; i++) vd.Insert(ellipses[i]); if (vd != null) BuildTriples(vd.NextTriple(vd.NullTriple), gg_triples, true); else gg_triples.Children.Clear(); triple = vd.NextTriple(vd.NullTriple); } }
private void Canvas_MouseDown(object sender, MouseButtonEventArgs e) { if (item != null) { stack_panel.Children.Remove(item); System.Windows.Point p = e.GetPosition(canvas); Circle t_circle = new Circle() { R = item.Width / 2, X = p.X, Y = p.Y }; ellipses.Add(t_circle); moves.Add(new Vector2d() { X = 100 * rand.NextDouble(), Y = 100 * rand.NextDouble() }); if (ellipses.Count == 2) { vd = new VD<Circle, DeloneCircle>(ellipses[0], ellipses[1], null); triple = vd.NextTriple(vd.NullTriple); } if (ellipses.Count > 2) { Triple<Circle, DeloneCircle> temp_triple = TestAlgorithms.Минимальновозможная_тройка(vd, t_circle); //TestAlgorithms.Placing(temp_triple.Vertex.Next.Data, t_circle, temp_triple.Vertex.Prev.Data); vd.Insert(t_circle); } if (vd != null) BuildTriples(vd.NextTriple(vd.NullTriple), gg_triples, true); else gg_triples.Children.Clear(); item = null; } }