Esempio n. 1
0
        private GeometricNode CreatePolygonNode(Polygon polygon, int i)
        {
            var polygonNode = new GeometricNode($"Polygon{i}", NodeType.Polygon, polygon);

            var edgesNode    = new GeometricNode("Edges", NodeType.EdgesList, null);
            var verticesNode = new GeometricNode("Vertices", NodeType.VerticesList, null);

            var edges = polygon.GetEdges();

            for (int j = 0; j < edges.Count; j++)
            {
                edgesNode.Nodes.Add(new GeometricNode("", NodeType.Edge, edges[j]));
            }

            UpdateEdgesLabels(edgesNode.Nodes);

            var vertices = polygon.GetVertices();

            for (int j = 0; j < vertices.Count; j++)
            {
                verticesNode.Nodes.Add(new GeometricNode($"Vertex{j}", NodeType.Vertex, vertices[j]));
            }

            polygonNode.Nodes.Add(edgesNode);
            polygonNode.Nodes.Add(verticesNode);

            return(polygonNode);
        }
Esempio n. 2
0
        private void UpdateNode(GeometricNode node, Polygon polygon, int i)
        {
            if (!node.Structure.Equals(polygon))
            {
                node = CreatePolygonNode(polygon, i);
                return;
            }

            UpdateEdges(node.Nodes[0].Nodes, polygon.GetEdges());
            UpdateVertices(node.Nodes[1].Nodes, polygon.GetVertices());
        }