Ejemplo n.º 1
0
        public VoronoiMap GimmesomeVeoroiois(List <VoronoiPoint> sites)
        {
            eventQ  = new FastPriorityQueue <FastSiteQueueNode>(sites.Count + 1);
            circleQ = new FastPriorityQueue <FastCircleQueueNode>(sites.Count * sites.Count);

            foreach (VoronoiPoint pt in sites)
            {
                var pointasevent = new SiteEvent(pt);
                eventQ.Enqueue(new FastSiteQueueNode(pointasevent), pointasevent.NodePriority);
            }

            while (eventQ.Count != 0)
            {
                if (circleQ.Count != 0 && circleQ.First().point.circleLength <= eventQ.First().point.X)
                {
                    ProcessCircleEvent();
                }
                else
                {
                    ProcessPointEvent();
                }
            }

            while (circleQ.Count != 0)
            {
                ProcessCircleEvent();
            }

            var finalmap = regionsT.FinishEdges();

            return(finalmap);
        }
Ejemplo n.º 2
0
        public void ProcessPointEvent()
        {
            var p            = eventQ.Dequeue().point;
            var pointAsEvent = new SiteEvent(p.basepoint);

            regionsT.AddToBeachLine(pointAsEvent);
            AddCreatedCircleEvents();
        }
Ejemplo n.º 3
0
        public void AddToBeachLine(SiteEvent newarcpoint)
        {
            if (BeachPoints is null)
            {
                BeachPoints = new Arc(newarcpoint);
            }
            else
            {
                knownSite = BeachPoints;
                while (!(knownSite is null))
                {
                    var intersection = FindIntersectedArc(newarcpoint, knownSite);
                    if (intersection.flag)
                    {
                        var nextpointcheckZ = FindIntersectedArc(newarcpoint, knownSite.nextpoint);
                        if (!(knownSite.nextpoint is null) && !nextpointcheckZ.flag)
                        {
                            knownSite.nextpoint.previouspoint = new Arc(knownSite.arcpoint, knownSite, knownSite.nextpoint);
                            knownSite.nextpoint = knownSite.nextpoint.previouspoint;
                        }
                        else
                        {
                            knownSite.nextpoint = new Arc(knownSite.arcpoint, knownSite);
                        }
                        knownSite.nextpoint.s1 = knownSite.s1;

                        knownSite.nextpoint.previouspoint = new Arc(newarcpoint, knownSite, knownSite.nextpoint);
                        knownSite.nextpoint = knownSite.nextpoint.previouspoint;

                        knownSite = knownSite.nextpoint;

                        var vifSeg = new VoronoiSegment(intersection.siteEvent.X, intersection.siteEvent.Y, knownSite, knownSite.previouspoint, 3);
                        knownSite.previouspoint.s1 = vifSeg;
                        knownSite.s0 = vifSeg;
                        VoronoiGraph.Add(vifSeg);
                        vifSeg                 = new VoronoiSegment(intersection.siteEvent.X, intersection.siteEvent.Y, knownSite.nextpoint, knownSite, 7);
                        knownSite.s1           = vifSeg;
                        knownSite.nextpoint.s0 = vifSeg;
                        VoronoiGraph.Add(vifSeg); //Yes this needs to be added twice
                        CheckForCircleEventsInTriple(newarcpoint.X);
                        return;
                    }
                    knownSite = knownSite.nextpoint ?? null;
                }
                knownSite = BeachPoints;
                while (!(knownSite.nextpoint is null))
                {
                    knownSite = knownSite.nextpoint;
                }
                knownSite.nextpoint = new Arc(newarcpoint, knownSite);
                var x            = _boundx0;
                var y            = (knownSite.nextpoint.arcpoint.Y + knownSite.arcpoint.Y) / 2.0;
                var segmentEvent = new SiteEvent(new VoronoiPoint(x, y));
                var vSeg         = new VoronoiSegment(segmentEvent.X, segmentEvent.Y, knownSite.nextpoint, knownSite, 1);
                VoronoiGraph.Add(vSeg);
                knownSite.s1           = vSeg;
                knownSite.nextpoint.s0 = vSeg;
            }
Ejemplo n.º 4
0
 public FastSiteQueueNode(SiteEvent eventpt)
 {
     point = eventpt;
 }
Ejemplo n.º 5
0
 public IntersectionFlag(bool fg, SiteEvent se)
 {
     flag = fg; siteEvent = se;
 }