コード例 #1
0
ファイル: LogEntry.cs プロジェクト: LuukvH/Voronoi-Game
        public LogEntry(string text, Graph graph)
        {
            Message = text;

            State = new Graph();
            State.Vertices.AddRange(graph.Vertices);
            State.Faces.AddRange(graph.Faces);
        }
コード例 #2
0
        private void DrawGraph(Graph graph)
        {
            canvas.Children.Clear();
            treeCanvas.Children.Clear();

            //DrawTree(_graph.Tree.Root);

            if (_drawfaces)
            {
                foreach (Face face in graph.Faces)
                {
                    DrawFace(face, Colors.Transparent);
                }

                foreach (Face face in graph.Faces)
                {
                    if (face is Triangle)
                    {
                        DrawLabel((face as Triangle).Center, $"F{face.Id:d}");
                    }
                }
            }

            if (_drawedges)
            {
                foreach (HalfEdge halfEdge in graph.HalfEdges)
                {
                    if (halfEdge.Origin.Distance(halfEdge.Next.Origin) >= 2 * _oneEuroRadius + 2 * _twoEuroRadius)
                    {
                        DrawEdge(halfEdge, Colors.Green, 2);
                    }
                    else
                    {
                        if (_labeling)
                        {
                            DrawEdge(halfEdge, Colors.Red, 2);
                        }
                        else
                        {
                            DrawEdge(halfEdge, Colors.Green, 2);
                        }
                    }
                }
            }

            // Draw _selected
            if (_selected != null)
            {
                DrawFace(_selected.Face, Colors.LightYellow);
                DrawEdge(_selected, Colors.YellowGreen, 3);
            }

            if (_drawcircles)
            {
                foreach (Face face in graph.Faces)
                {
                    if (face is Triangle)
                    {
                        Triangle triangle = face as Triangle;
                        DrawCircumcenter(triangle);
                    }
                }
            }

            if (_drawvoronoi)
            {
                DrawVoronoi();
            }

            foreach (Vertex vertex in graph.Vertices)
            {
                DrawVertex(vertex, Colors.Black);
            }
        }