Esempio n. 1
0
 public virtual void AddChild(Node childNode)
 {
     Children.Add(childNode);
     childNode.Parent = this;
     childNode.Ancestors.AddAll(this.Ancestors);
     childNode.Ancestors.Add(this);
     this.Descendants.Add(childNode);
 }
Esempio n. 2
0
        private Node Search(Node node, Vertex vertex)
        {
            foreach (Node childNode in node.Children)
            {
                if (childNode.Face.Inside(vertex))
                {
                    return Search(childNode, vertex);
                }
            }

            return node;
        }
Esempio n. 3
0
 public Tree(Face root)
 {
     Root = new Node(root);
 }
Esempio n. 4
0
        private void DrawTree(Node root, int level = 0, float scale = 1.0f)
        {
            for (int index = 0; index < root.Children.Count; index++)
            {
                Node node = root.Children[index];
                float localscale = scale * 1f / (root.Children.Count + 1) * (index + 1);

                float radius = 20;
                SolidColorBrush solidColorBrush = new SolidColorBrush { Color = Colors.Red };
                Ellipse elipse = new Ellipse
                {
                    Stroke = solidColorBrush,
                    Width = radius * 2,
                    Height = radius * 2
                };

                treeCanvas.Children.Add(elipse);
                Canvas.SetLeft(elipse, (treeCanvas.ActualWidth * scale) + (localscale * treeCanvas.ActualWidth) - radius);
                Canvas.SetTop(elipse, 50 * (level + 1) - radius);

                Label label = new Label
                {
                    Content = $"F{node.Face.Id:d}",
                    Foreground = solidColorBrush,
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                    VerticalContentAlignment = VerticalAlignment.Center,
                    Width = radius * 2,
                    Height = radius * 2
                };

                Canvas.SetLeft(label, treeCanvas.ActualWidth * localscale - radius);
                Canvas.SetTop(label, 50 * (level + 1) - radius);
                treeCanvas.Children.Add(label);

                DrawTree(node, level + 1, localscale);
            }
        }