Beispiel #1
0
        public Point3D GetRandom()
        {
            if (Facet == null || Facet == Map.Internal || Count == 0)
            {
                return(Point3D.Zero);
            }

            if (Count <= 1024)
            {
                return(_Points.Values.ElementAt(Utility.Random(Count)));
            }

            int x, y;

            do
            {
                x = Utility.RandomMinMax(_Bounds.Start.X, _Bounds.End.X);
                y = Utility.RandomMinMax(_Bounds.Start.Y, _Bounds.End.Y);
            }while (!Contains(x, y));

            var z = Facet.GetAverageZ(x, y);

            if (Validator == null || Validator(Facet, x, y, z))
            {
                return(new Point3D(x, y, z));
            }

            return(GetRandom());
        }