Example #1
0
        private static IEnumerable <DelaunayEdge> FindHoleBoundaries(
            IEnumerable <DelaunayTriangle> badTriangles)
        {
            var boundaryEdges  = new List <DelaunayEdge>();
            var duplicateEdges = new List <DelaunayEdge>();

            foreach (var triangle in badTriangles)
            {
                for (var i = 0; i < triangle.Vertices.Count; i++)
                {
                    var e = new DelaunayEdge(
                        triangle.Vertices[i],
                        triangle.Vertices[(i + 1) % triangle.Vertices.Count]);
                    if (!boundaryEdges.Contains(e))
                    {
                        boundaryEdges.Add(e);
                    }
                    else
                    {
                        duplicateEdges.Add(e);
                    }
                }
            }

            for (var i = boundaryEdges.Count - 1; i >= 0; i--)
            {
                var e = boundaryEdges[i];
                if (duplicateEdges.Contains(e))
                {
                    boundaryEdges.Remove(e);
                }
            }

            return(boundaryEdges);
        }
Example #2
0
        public void CanCompare_DelaunayEdges()
        {
            var edgeA = new DelaunayEdge(new DelaunayPoint(0, 0), new DelaunayPoint(1, 0));
            var edgeB = new DelaunayEdge(new DelaunayPoint(0, 0), new DelaunayPoint(1, 0));

            Assert.Equal(edgeA, edgeB);
            Assert.Equal(edgeA.GetHashCode(), edgeB.GetHashCode());
            Assert.NotNull(edgeA);
        }
Example #3
0
        public Path CreateLineForMinSpanningTreeEdge(DelaunayEdge edge)
        {
            if (this.minimumSpanningTreePaths == null)
            {
                this.minimumSpanningTreePaths = new Dictionary<DelaunayEdge, Path>();
            }

            if (!this.minimumSpanningTreePaths.ContainsKey(edge))
            {
                LineGeometry geometry = new LineGeometry(new Point(edge.Start.X, edge.Start.Y), new Point(edge.End.X, edge.End.Y));
                geometry.Freeze();
                Path path = new Path();
                path.Data = geometry;
                path.StrokeThickness = MinimumSpanningTreeTickness;
                path.Stroke = new SolidColorBrush(Color.FromArgb(120, minimumSpanningTreeEdgeColor.A, minimumSpanningTreeEdgeColor.G, minimumSpanningTreeEdgeColor.B));
                this.minimumSpanningTreePaths[edge] = path;
            }
            return this.minimumSpanningTreePaths[edge];
        }
Example #4
0
        public Path CreateEdgeLine(DelaunayEdge edge)
        {
            if (this.edgesPaths == null)
            {
                this.edgesPaths = new Dictionary<DelaunayEdge, Path>();
            }

            if (!this.edgesPaths.ContainsKey(edge))
            {
                LineGeometry geometry = new LineGeometry(new Point(edge.Start.X, edge.Start.Y), new Point(edge.End.X, edge.End.Y));
                geometry.Freeze();
                Path path = new Path();
                path.Data = geometry;
                path.StrokeThickness = EdgeTickness;
                path.Stroke = new SolidColorBrush(EdgeColor);
                this.edgesPaths[edge] = path;
            }
            return this.edgesPaths[edge];
        }