protected ReferencePointBasedTransform(MappingGridVector2[] points, GridRectangle mappedBounds, GridRectangle controlBounds, TransformInfo info)
     : base(info)
 {
     this.MapPoints = points;
     this.MappedBounds = mappedBounds;
     this.ControlBounds = controlBounds;
 }
        protected ReferencePointBasedTransform(MappingGridVector2[] points, TransformInfo info)
            : base(info)
        {
            //List<MappingGridVector2> listPoints = new List<MappingGridVector2>(points);
            //MappingGridVector2.RemoveDuplicates(listPoints);

            //this.MapPoints = listPoints.ToArray();
            this.MapPoints = points;
        }
Example #3
0
        public GridTransform(MappingGridVector2[] points, GridRectangle mappedBounds, int gridSizeX, int gridSizeY, TransformInfo info)
            : base(points, mappedBounds, info)
        {
            GridSizeX = gridSizeX;
            GridSizeY = gridSizeY;

            Array.Sort(points);

            Debug.Assert(points.Length == gridSizeX * gridSizeY, "Invalid argument to GridTransform constructor.  Number of points incorrect");
            if (points.Length != gridSizeX * gridSizeY)
            {
                throw new ArgumentException("GridTransform constructor. Number of points incorrect");
            }

            _TriangleIndicies = GridTransformHelper.TrianglesForGrid(GridSizeX, GridSizeY);
        }
Example #4
0
 protected TransformBase(TransformInfo info)
 {
     Info = info;
 }
 protected ReferencePointBasedTransform(MappingGridVector2[] points, GridRectangle mappedBounds, TransformInfo info)
     : this(points, info)
 {
     this.MappedBounds = mappedBounds;
 }
Example #6
0
        private static ReferencePointBasedTransform ParseTranslateTransform(TransformParameters transform, TransformInfo info)
        {
            if (transform == null)
                throw new ArgumentNullException("transform");

            //string filename = System.IO.Path.GetFileName(parts[1]);

            //Figure out tile size if we haven't already
            int ImageWidth = System.Convert.ToInt32(transform.fixedParameters[2]) * 2;
            int ImageHeight = System.Convert.ToInt32(transform.fixedParameters[3]) * 2;

            double x = transform.variableParameters[0];
            double y = transform.variableParameters[1];

            GridVector2 ctrlBotLeft = new GridVector2(x, y);
            GridVector2 ctrlBotRight = new GridVector2(x + ImageWidth, y);
            GridVector2 ctrlTopLeft = new GridVector2(x, y + ImageHeight);
            GridVector2 ctrlTopRight = new GridVector2(x + ImageWidth, y + ImageHeight);

            GridVector2 mapBotLeft = new GridVector2(0, 0);
            GridVector2 mapBotRight = new GridVector2(ImageWidth, 0);
            GridVector2 mapTopLeft = new GridVector2(0, ImageHeight);
            GridVector2 mapTopRight = new GridVector2(ImageWidth, ImageHeight);

            MappingGridVector2 BotLeft = new MappingGridVector2(ctrlBotLeft, mapBotLeft);
            MappingGridVector2 BotRight = new MappingGridVector2(ctrlBotRight, mapBotRight);
            MappingGridVector2 TopLeft = new MappingGridVector2(ctrlTopLeft, mapTopLeft);
            MappingGridVector2 TopRight = new MappingGridVector2(ctrlTopRight, mapTopRight);

            MappingGridVector2[] mapPoints = new MappingGridVector2[] { BotLeft, BotRight, TopLeft, TopRight };

            return new GridTransform(mapPoints, new GridRectangle(0, ImageWidth, 0, ImageHeight), 2, 2, info);
        }
Example #7
0
        private static ReferencePointBasedTransform ParsePolyTransform(TransformParameters transform, TransformInfo info)
        {
            //            string filename = System.IO.Path.GetFileName(parts[1]);
            //            string[] fileparts = filename.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
            //            this.Number = System.Convert.ToInt32(fileparts[1]);

            //Figure out tile size
            int ImageWidth = System.Convert.ToInt32(transform.fixedParameters[2]) * 2;
            int ImageHeight = System.Convert.ToInt32(transform.fixedParameters[3]) * 2;

            //The poly transform parameters dictate the center of the image
            double x = transform.fixedParameters[0] - (ImageWidth / 2.0);
            double y = transform.fixedParameters[1] - (ImageHeight / 2.0);

            GridVector2 ctrlBotLeft = new GridVector2(x, y);
            GridVector2 ctrlBotRight = new GridVector2(x + ImageWidth, y);
            GridVector2 ctrlTopLeft = new GridVector2(x, y + ImageHeight);
            GridVector2 ctrlTopRight = new GridVector2(x + ImageWidth, y + ImageHeight);

            GridVector2 mapBotLeft = new GridVector2(0, 0);
            GridVector2 mapBotRight = new GridVector2(ImageWidth, 0);
            GridVector2 mapTopLeft = new GridVector2(0, ImageHeight);
            GridVector2 mapTopRight = new GridVector2(ImageWidth, ImageHeight);

            MappingGridVector2 BotLeft = new MappingGridVector2(ctrlBotLeft, mapBotLeft);
            MappingGridVector2 BotRight = new MappingGridVector2(ctrlBotRight, mapBotRight);
            MappingGridVector2 TopLeft = new MappingGridVector2(ctrlTopLeft, mapTopLeft);
            MappingGridVector2 TopRight = new MappingGridVector2(ctrlTopRight, mapTopRight);

            MappingGridVector2[] MapPoints = new MappingGridVector2[] { BotLeft, BotRight, TopLeft, TopRight };

            return new GridTransform(MapPoints, new GridRectangle(0, ImageWidth, 0, ImageHeight), 2, 2, info);
        }
Example #8
0
        private static ReferencePointBasedTransform ParseMosaicTileEntry(string transformString, TransformInfo info)
        {
            TransformParameters transform = TransformParameters.Parse(transformString);

            switch (transform.transform_name.ToLower())
            {
                case "GridTransform_double_2_2":
                    return ParseGridTransform(transform, info);

                case "LegendrePolynomialTransform_double_2_2_1":
                    return ParsePolyTransform(transform, info);

                case "TranslationTransform_double_2_2":
                    return ParseTranslateTransform(transform, info);

                case "meshtransform_double_2_2":
                    return ParseMeshTransform(transform, info);

                case "MeshTransform_double_2_2":
                    return ParseMeshTransform(transform, info);

                default:
                    Debug.Assert(false, "Unexpected transform type: " + transform.transform_name);
                    break;
            }

            return null;
        }
Example #9
0
        private static MeshTransform ParseMeshTransform(TransformParameters transform, TransformInfo info, double PixelSpacing= 1.0 )
        {
            int NumVariableParameters = transform.variableParameters.Length;
            Debug.Assert(NumVariableParameters % 4 == 0);
            int NumPoints = NumVariableParameters / 4;

            double Left = System.Convert.ToInt32(transform.fixedParameters[3] * PixelSpacing);
            double Bottom = System.Convert.ToInt32(transform.fixedParameters[4] * PixelSpacing);
            double ImageWidth = System.Convert.ToInt32(transform.fixedParameters[5] * PixelSpacing);
            double ImageHeight = System.Convert.ToInt32(transform.fixedParameters[6] * PixelSpacing);

            MappingGridVector2[] Points = new MappingGridVector2[NumPoints];

            for (int iP = 0; iP < NumPoints; iP++)
            {
                int iOffset = (iP * 4);
                GridVector2 Mapped = new GridVector2((transform.variableParameters[iOffset] * ImageWidth) + Left,
                                                     (transform.variableParameters[iOffset+1] * ImageHeight) + Bottom);
                GridVector2 Control = new GridVector2(transform.variableParameters[iOffset+2] * PixelSpacing,
                                                     transform.variableParameters[iOffset+3] * PixelSpacing);

                Points[iP] = new MappingGridVector2(Control, Mapped);
            }

            return new MeshTransform(Points, info);
        }
Example #10
0
        private static GridTransform ParseGridTransform(TransformParameters transform, double PixelSpacing, TransformInfo info)
        {
            //string filename = System.IO.Path.GetFileName(parts[1]);
            //string[] fileparts = filename.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
            //this.Number = System.Convert.ToInt32(fileparts[1]);

            int gridWidth = System.Convert.ToInt32(transform.fixedParameters[2] + 1.0);
            int gridHeight = System.Convert.ToInt32(transform.fixedParameters[1] + 1.0);

            int ImageWidth = System.Convert.ToInt32(transform.fixedParameters[5] * PixelSpacing);
            int ImageHeight = System.Convert.ToInt32(transform.fixedParameters[6] * PixelSpacing);

            GridRectangle MappedBounds = new GridRectangle(0, ImageWidth, 0, ImageHeight);

            int NumPts = transform.variableParameters.Length / 2;
            GridVector2[] Points = new GridVector2[NumPts];

            //           verticies = new VertexPositionNormalTexture[numPts];

            Double minX = Double.MaxValue;
            Double minY = Double.MaxValue;
            Double maxX = Double.MinValue;
            Double maxY = Double.MinValue;

            //Every number in the array is seperated by an empty space in the array
            for (int i = 0; i < NumPts; i++)
            {
                int iPoint = (i * 2);
                Double x = transform.variableParameters[iPoint] * PixelSpacing;
                Double y = transform.variableParameters[iPoint+1] * PixelSpacing;

                Points[i] = new GridVector2(x, y);

                //Trace.WriteLine(x.ToString() + ", " + y.ToString(), "Geometry");
                if (x < minX)
                    minX = x;
                if (x > maxX)
                    maxX = x;
                if (y < minY)
                    minY = y;
                if (y > maxY)
                    maxY = y;
            }

            //            List<int> indicies = new List<int>();
            MappingGridVector2[] mapList = new MappingGridVector2[gridHeight * gridWidth];
            List<int> triangleIndicies = new List<int>();

            for (int y = 0; y < gridHeight; y++)
            {
                for (int x = 0; x < gridWidth; x++)
                {
                    int i = x + (y * gridWidth);

                    GridVector2 mapPoint = GridTransform.CoordinateFromGridPos(x, y, gridWidth, gridHeight, ImageWidth,ImageHeight);
                    GridVector2 ctrlPoint = Points[i];

                    MappingGridVector2 gridPoint = new MappingGridVector2(ctrlPoint, mapPoint);
                    mapList[i] = gridPoint;
                }
            }

            for (int y = 0; y < gridHeight - 1; y++)
            {
                for (int x = 0; x < gridWidth - 1; x++)
                {
                    int botLeft = x + (y * gridWidth);
                    int botRight = (x + 1) + (y * gridWidth);
                    int topLeft = x + ((y + 1) * gridWidth);
                    int topRight = (x + 1) + ((y + 1) * gridWidth);

                    int[] triangles = new int[] { botLeft, botRight, topLeft, botRight, topRight, topLeft };
                    triangleIndicies.AddRange(triangles);
                }
            }

            return new GridTransform(mapList, MappedBounds, gridWidth, gridHeight, info);
        }
Example #11
0
 private static GridTransform ParseGridTransform(TransformParameters transform, TransformInfo info)
 {
     return ParseGridTransform(transform, 1, info);
 }
Example #12
0
 public RBFTransform(MappingGridVector2[] points, TransformInfo info)
     : base(points, info)
 {
 }