Esempio n. 1
0
        /// <summary>
        /// Will return the new root (unchanged except in start-up)
        /// </summary>
        public static VNode ProcessDataEvent(VDataEvent e, VNode Root, VoronoiGraph VG, float ys, out VDataNode[] CircleCheckList)
        {
            if (Root == null)
            {
                Root            = new VDataNode(e.DataPoint);
                CircleCheckList = new VDataNode[] { (VDataNode)Root };
                return(Root);
            }
            //1. Find the node to be replaced
            VNode C = VNode.FindDataNode(Root, ys, e.DataPoint[0]);
            //2. Create the subtree (ONE Edge, but two VEdgeNodes)
            VoronoiEdge VE = new VoronoiEdge();

            VE.LeftData  = ((VDataNode)C).DataPoint;
            VE.RightData = e.DataPoint;
            VE.VVertexA  = Fortune.VVUnkown;
            VE.VVertexB  = Fortune.VVUnkown;
            VG.Edges.Add(VE);

            VNode SubRoot;

            if (Math.Abs(VE.LeftData[1] - VE.RightData[1]) < 1e-10)
            {
                if (VE.LeftData[0] < VE.RightData[0])
                {
                    SubRoot       = new VEdgeNode(VE, false);
                    SubRoot.Left  = new VDataNode(VE.LeftData);
                    SubRoot.Right = new VDataNode(VE.RightData);
                }
                else
                {
                    SubRoot       = new VEdgeNode(VE, true);
                    SubRoot.Left  = new VDataNode(VE.RightData);
                    SubRoot.Right = new VDataNode(VE.LeftData);
                }
                CircleCheckList = new VDataNode[] { (VDataNode)SubRoot.Left, (VDataNode)SubRoot.Right };
            }
            else
            {
                SubRoot             = new VEdgeNode(VE, false);
                SubRoot.Left        = new VDataNode(VE.LeftData);
                SubRoot.Right       = new VEdgeNode(VE, true);
                SubRoot.Right.Left  = new VDataNode(VE.RightData);
                SubRoot.Right.Right = new VDataNode(VE.LeftData);
                CircleCheckList     = new VDataNode[] { (VDataNode)SubRoot.Left, (VDataNode)SubRoot.Right.Left, (VDataNode)SubRoot.Right.Right };
            }

            //3. Apply subtree
            if (C.Parent == null)
            {
                return(SubRoot);
            }
            C.Parent.Replace(C, SubRoot);
            return(Root);
        }
Esempio n. 2
0
        /// <summary>
        /// Will return the new root (unchanged except in start-up)
        /// </summary>
        public static VNode ProcessDataEvent(VDataEvent e, VNode Root, VoronoiGraph VG, double ys, out VDataNode[] CircleCheckList)
        {
            if(Root==null)
            {
                Root = new VDataNode(e.DataPoint);
                CircleCheckList = new VDataNode[] {(VDataNode)Root};
                return Root;
            }
            //1. Find the node to be replaced
            VNode C = VNode.FindDataNode(Root, ys, e.DataPoint.X);
            //2. Create the subtree (ONE Edge, but two VEdgeNodes)
            VoronoiEdge VE = new VoronoiEdge();
            VE.LeftData = ((VDataNode)C).DataPoint;
            VE.RightData = e.DataPoint;
            VE.VVertexA = Fortune.VVUnkown;
            VE.VVertexB = Fortune.VVUnkown;
            VG.Edges.Add(VE);

            VNode SubRoot;
            if(Math.Abs(VE.LeftData.Y-VE.RightData.Y)<1e-10)
            {
                if(VE.LeftData.X<VE.RightData.X)
                {
                    SubRoot = new VEdgeNode(VE,false);
                    SubRoot.Left = new VDataNode(VE.LeftData);
                    SubRoot.Right = new VDataNode(VE.RightData);
                }
                else
                {
                    SubRoot = new VEdgeNode(VE,true);
                    SubRoot.Left = new VDataNode(VE.RightData);
                    SubRoot.Right = new VDataNode(VE.LeftData);
                }
                CircleCheckList = new VDataNode[] {(VDataNode)SubRoot.Left,(VDataNode)SubRoot.Right};
            }
            else
            {
                SubRoot = new VEdgeNode(VE,false);
                SubRoot.Left = new VDataNode(VE.LeftData);
                SubRoot.Right = new VEdgeNode(VE,true);
                SubRoot.Right.Left = new VDataNode(VE.RightData);
                SubRoot.Right.Right = new VDataNode(VE.LeftData);
                CircleCheckList = new VDataNode[] {(VDataNode)SubRoot.Left,(VDataNode)SubRoot.Right.Left,(VDataNode)SubRoot.Right.Right};
            }

            //3. Apply subtree
            if(C.Parent == null)
                return SubRoot;
            C.Parent.Replace(C,SubRoot);
            return Root;
        }
Esempio n. 3
0
        /// <summary>
        /// Will return the new root (unchanged except in start-up)
        /// </summary>
        public static VNode ProcessDataEvent(VDataEvent e, VNode root, VoronoiGraph vg, double ys, out VDataNode[] circleCheckList)
        {
            if (root == null)
            {
                root            = new VDataNode(e.DataPoint);
                circleCheckList = new[] { (VDataNode)root };
                return(root);
            }
            //1. Find the node to be replaced
            VNode c = FindDataNode(root, ys, e.DataPoint[0]);
            //2. Create the subtree (ONE Edge, but two VEdgeNodes)
            var ve = new VoronoiEdge {
                LeftData  = ((VDataNode)c).DataPoint,
                RightData = e.DataPoint,
                VVertexA  = Fortune.VvUnkown,
                VVertexB  = Fortune.VvUnkown
            };

            vg.Edges.Add(ve);

            VNode subRoot;

            if (Math.Abs(ve.LeftData[1] - ve.RightData[1]) < 1e-10)
            {
                if (ve.LeftData[0] < ve.RightData[0])
                {
                    subRoot = new VEdgeNode(ve, false)
                    {
                        Left  = new VDataNode(ve.LeftData),
                        Right = new VDataNode(ve.RightData)
                    };
                }
                else
                {
                    subRoot = new VEdgeNode(ve, true)
                    {
                        Left  = new VDataNode(ve.RightData),
                        Right = new VDataNode(ve.LeftData)
                    };
                }
                circleCheckList = new[] { (VDataNode)subRoot.Left, (VDataNode)subRoot.Right };
            }
            else
            {
                subRoot = new VEdgeNode(ve, false)
                {
                    Left  = new VDataNode(ve.LeftData),
                    Right = new VEdgeNode(ve, true)
                    {
                        Left  = new VDataNode(ve.RightData),
                        Right = new VDataNode(ve.LeftData)
                    }
                };
                circleCheckList = new[] { (VDataNode)subRoot.Left, (VDataNode)subRoot.Right.Left, (VDataNode)subRoot.Right.Right };
            }

            //3. Apply subtree
            if (c.Parent == null)
            {
                return(subRoot);
            }
            c.Parent.Replace(c, subRoot);
            return(root);
        }
Esempio n. 4
0
        /// <summary>
        /// Will return the new root (unchanged except in start-up)
        /// </summary>
        public static VNode ProcessDataEvent(VDataEvent e, VNode root, VoronoiGraph vg, double ys, out VDataNode[] circleCheckList)
        {
            if (root == null)
            {
                root = new VDataNode(e.DataPoint);
                circleCheckList = new VDataNode[] { (VDataNode)root };
                return root;
            }
            //1. Find the node to be replaced
            VNode c = FindDataNode(root, ys, e.DataPoint.X);
            //2. Create the subtree (ONE Edge, but two VEdgeNodes)
            var ve = new Edge
            {
                LeftData = ((VDataNode)c).DataPoint,
                RightData = e.DataPoint,
                VVertexA = null,
                VVertexB = null
            };
            vg.MutableEdges.Add(ve);

            VNode subRoot;
            if (Math.Abs(ve.LeftData.Y - ve.RightData.Y) < 1e-10)
            {
                if (ve.LeftData.X < ve.RightData.X)
                {
                    subRoot = new VEdgeNode(ve, false)
                    {
                        Left = new VDataNode(ve.LeftData),
                        Right = new VDataNode(ve.RightData)
                    };
                }
                else
                {
                    subRoot = new VEdgeNode(ve, true)
                    {
                        Left = new VDataNode(ve.RightData),
                        Right = new VDataNode(ve.LeftData)
                    };
                }
                circleCheckList = new VDataNode[] { (VDataNode)subRoot.Left, (VDataNode)subRoot.Right };
            }
            else
            {
                subRoot = new VEdgeNode(ve, false)
                {
                    Left = new VDataNode(ve.LeftData),
                    Right = new VEdgeNode(ve, true)
                    {
                        Left = new VDataNode(ve.RightData),
                        Right = new VDataNode(ve.LeftData)
                    }
                };
                circleCheckList = new VDataNode[] { (VDataNode)subRoot.Left, (VDataNode)subRoot.Right.Left, (VDataNode)subRoot.Right.Right };
            }

            //3. Apply subtree
            if (c.Parent == null)
                return subRoot;
            c.Parent.Replace(c, subRoot);
            return root;
        }