Example #1
0
        public PointSet(int n)
        {
            NumPoints = n;
            Pt        = new WeightedPoint[n];
            Random r1 = new Random(2);


            //generate points in random
            while (n > 0)
            {
                int XLoc = r1.Next(100);
                int YLoc = r1.Next(100);
                if (exists(XLoc, YLoc, n))
                {
                    continue;
                }
                n--;
                Pt[n] = new WeightedPoint(XLoc, YLoc, 0);
            }
            for (int i = 0; i < NumPoints; i++)
            {
                Pt[i].X *= 3;
                Pt[i].Y *= 3;
            }
        }
        public PointSet(int n, Tiling g, int pointsPerLevel)
        {
            NumPoints = n;
            Pt        = new WeightedPoint[n + 1];
#if SHARPKIT //https://code.google.com/p/sharpkit/issues/detail?id=340
            throw new InvalidOperationException();
#else
            pointMap = new int[g.NumOfnodes + 1, g.NumOfnodes + 1];
#endif
            _selected = new int[g.NumOfnodes + 1];
            Random r1 = new Random(1);


            //generate points in random
            while (n > 0)
            {
                var temp = r1.Next(1, g.NumOfnodes); //,temp2;
                if (_selected[temp] == 1 || (g.VList[temp].XLoc + g.VList[temp].YLoc) % 2 == 1)
                {
                    continue;
                }
                Pt[n]           = new WeightedPoint(g.VList[temp].XLoc, g.VList[temp].YLoc, 0);
                _selected[temp] = 1;
                //compute weight based on point density
                Pt[n].GridPoint      = temp;
                g.VList[temp].Weight = Pt[n].Weight;
                n--;
            }
            AssignWeight(Pt, NumPoints, (int)Math.Sqrt(g.NumOfnodes));


            NumOfLevels = NumPoints / pointsPerLevel;
            if (NumPoints % pointsPerLevel > 0)
            {
                NumOfLevels++;
            }

            for (int index = 1; index <= NumPoints; index++)
            {
                Pt[index].ZoomLevel = 1 + (index - 1) / pointsPerLevel;
            }

            for (int i = 1; i <= NumPoints; i++)
            {
                g.VList[Pt[i].GridPoint].Weight    = Pt[i].Weight;
                g.VList[Pt[i].GridPoint].ZoomLevel = Pt[i].ZoomLevel;
                pointMap[Pt[i].X, Pt[i].Y]         = i;
            }
        }
Example #3
0
        public PointSet(int n, Tiling g, int pointsPerLevel)
        {
            NumPoints = n;
            Pt        = new WeightedPoint[n + 1];
            pointMap  = new int[g.NumOfnodes + 1, g.NumOfnodes + 1];

            _selected = new int[g.NumOfnodes + 1];
            Random r1 = new Random();

            //List<int> list = new List<int>();

            //for (int i = 1; i < 255; i++)
            //{
            //list.Add(i);
            //}


            //generate points in random
            while (n > 0)
            {
                var temp = r1.Next(1, g.NumOfnodes); //,temp2;
                if (_selected[temp] == 1 || (g.VList[temp].XLoc + g.VList[temp].YLoc) % 2 == 1)
                {
                    continue;
                }
                Pt[n]           = new WeightedPoint(g.VList[temp].XLoc, g.VList[temp].YLoc, 0);
                _selected[temp] = 1;
                //compute weight based on point density
                //temp2 = r2.Next(1, list.Count);
                //pt[n] = new Point(g.vList[temp].x_loc, g.vList[temp].y_loc, (int) list.ElementAt(temp2));
                //list.RemoveAt(temp2);
                Pt[n].GridPoint      = temp;
                g.VList[temp].Weight = Pt[n].Weight;
                n--;
            }
            AssignWeight(Pt, NumPoints, (int)Math.Sqrt(g.NumOfnodes));


            NumOfLevels = NumPoints / pointsPerLevel;
            if (NumPoints % pointsPerLevel > 0)
            {
                NumOfLevels++;
            }

            for (int index = 1; index <= NumPoints; index++)
            {
                Pt[index].ZoomLevel = 1 + (index - 1) / pointsPerLevel;
            }

            for (int i = 1; i <= NumPoints; i++)
            {
                Debug.WriteLine(Pt[i].Weight);
                g.VList[Pt[i].GridPoint].Weight    = Pt[i].Weight;
                g.VList[Pt[i].GridPoint].ZoomLevel = Pt[i].ZoomLevel;
                pointMap[Pt[i].X, Pt[i].Y]         = i;
            }

            //random shuffle
            //int p1;
            //for (int i = 1; i <= 10000; i++)
            //{
            //    p1 = r1.Next(1, num_points);
            //    pt[p1].weight = r2.Next(10, 255);
            //    g.vList[pt[p1].grid_point].weight = pt[p1].weight;
            //}
        }