Example #1
0
        private static List <Point> ConstructRasterSFC(Point startPoint, int height, int width, SpaceFillingCurve sFC)
        {
            List <Point> result = new List <Point>();

            if (height * width == sFC.NumberOfSteps)
            {
                return(sFC.TraverseTheBasePath(startPoint));
            }

            int newHeight = height / sFC.BaseSize;

            int newWidth = width / sFC.BaseSize;

            Point tempPoint = startPoint;

            for (int i = 0; i < sFC.NumberOfSteps; i++)
            {
                SpaceFillingCurve temp = sFC.CalculateSubregionBMFs(i);

                result.AddRange(ConstructRasterSFC(tempPoint, newHeight, newWidth, temp));

                if (i == sFC.NumberOfSteps - 1)
                {
                    continue;
                }

                tempPoint = sFC.MoveToNextRegion(i, tempPoint, newWidth);
            }

            return(result);
        }
Example #2
0
        public static Point TransformIndexToPoint(SpaceFillingCurve sFC, int index, int size)
        {
            List <int> baseRepresentation = new List <int>();

            int baseValue = sFC.NumberOfSteps;

            int outputLength = (int)Math.Log(size, sFC.BaseSize);

            int temp = index;

            do
            {
                baseRepresentation.Add(temp % baseValue);

                temp = temp / baseValue;
            } while (temp >= 1 || baseRepresentation.Count < outputLength);

            baseRepresentation.Reverse();

            Point startPoint = sFC.GetStartPointRelativeLocation();

            startPoint = new Point(startPoint.X * (size - 1) / (sFC.BaseSize - 1), startPoint.Y * (size - 1) / (sFC.BaseSize - 1));

            for (int i = 0; i < baseRepresentation.Count; i++)
            {
                size = size / sFC.BaseSize;

                if (size == 1)
                {
                    for (int j = 0; j < baseRepresentation[i]; j++)
                    {
                        startPoint = sFC[j](startPoint, 1);
                    }
                }
                else
                {
                    for (int j = 0; j < baseRepresentation[i]; j++)
                    {
                        startPoint = sFC.MoveToNextRegion(j, startPoint, size);
                    }
                }

                sFC = sFC.CalculateSubregionBMFs(baseRepresentation[i]);
            }

            return(startPoint);
        }
Example #3
0
        private static List <double> Project2DDataTo1D(Point startPoint, int height, int width, double[,] values, SpaceFillingCurve sFC)
        {
            List <double> result = new List <double>();

            if (height * width == sFC.NumberOfSteps)
            {
                List <Point> temp = sFC.TraverseTheBasePath(startPoint);

                List <double> tempResult = new List <double>();

                foreach (Point item in temp)
                {
                    tempResult.Add(values[(int)item.X, (int)item.Y]);
                }

                return(tempResult);
            }

            int newHeight = height / sFC.BaseSize;

            int newWidth = width / sFC.BaseSize;

            Point tempPoint = startPoint;

            for (int i = 0; i < sFC.NumberOfSteps; i++)
            {
                SpaceFillingCurve temp = sFC.CalculateSubregionBMFs(i);

                result.AddRange(Project2DDataTo1D(tempPoint, newHeight, newWidth, values, temp));

                if (i == sFC.NumberOfSteps - 1)
                {
                    continue;
                }

                tempPoint = sFC.MoveToNextRegion(i, tempPoint, newWidth);
            }

            return(result);
        }