Esempio n. 1
0
        // ----
        // ----
        // ||----
        // ||----
        // --||
        // --||

        public override List <Tuple <double, double> > calculate_polygon_coordinates(int i, int j)
        {
            //For the mesh TILED_RECTANGLE1
            Rectangle1CoordinateCalculator rc = new Rectangle1CoordinateCalculator();

            List <Tuple <double, double> > squareCoords = rc.calculate_polygon_coordinates(i / 2, j / 2);
            Tuple <double, double>         nullCoords   = squareCoords[0];
            Tuple <double, double>         oneCoords    = squareCoords[2];

            double x0 = nullCoords.Item1 * 2;
            double y0 = nullCoords.Item2 * 2;
            double x1 = oneCoords.Item1 * 2;
            double y1 = oneCoords.Item2 * 2;

            if (i % 4 < 2)   // --
            {
                x1 = x0 + 2; // --
                y1 = y0 + 1;
                if (i % 4 == 0)
                {
                    y0 = y0 - 1;
                    y1 = y1 - 1;
                }
            }
            else if (i % 4 >= 2) // ||
            {
                x1 = x0 + 1;     // ||
                y1 = y0 + 2;
                if (i % 4 == 3)
                {
                    x0 = x0 - 1;
                    x1 = x1 - 1;
                }
            }
            Tuple <double, double>         p0     = new Tuple <double, double>(x0, y0);
            Tuple <double, double>         p1     = new Tuple <double, double>(x1, y0);
            Tuple <double, double>         p2     = new Tuple <double, double>(x1, y1);
            Tuple <double, double>         p3     = new Tuple <double, double>(x0, y1);
            List <Tuple <double, double> > points = new List <Tuple <double, double> >();

            points.Add(p0);
            points.Add(p1);
            points.Add(p2);
            points.Add(p3);
            return(points);
        }
        public CoordinateCalculator produce(MeshType mesh)
        {
            CoordinateCalculator cc = new SquareCoordinateCalculator();

            if (mesh == MeshType.TRIANGLE)
            {
                cc = new TriangleCoordinateCalculator();
            }
            else if (mesh == MeshType.HEXAGON)
            {
                cc = new HexagonCoordinateCalculator();
            }
            else if (mesh == MeshType.PENTAGON1)
            {
                cc = new Pentagon1CoordinateCalculator();
            }
            else if (mesh == MeshType.PENTAGON3)
            {
                cc = new Pentagon3CoordinateCalculator();
            }
            else if (mesh == MeshType.PENTAGON4)
            {
                cc = new Pentagon4CoordinateCalculator();
            }
            else if (mesh == MeshType.KITE5)
            {
                cc = new Kite5CoordinateCalculator();
            }
            else if (mesh == MeshType.PENTAGON10)
            {
                cc = new Pentagon10CoordinateCalculator();
            }
            else if (mesh == MeshType.PENTAGON11)
            {
                cc = new Pentagon11CoordinateCalculator();
            }
            else if (mesh == MeshType.PENTAGON12)
            {
                cc = new Pentagon12CoordinateCalculator();
            }
            else if (mesh == MeshType.PENTAGON14)
            {
                cc = new Pentagon14CoordinateCalculator();
            }
            else if (mesh == MeshType.RECTANGLE1)
            {
                cc = new Rectangle1CoordinateCalculator();
            }
            else if (mesh == MeshType.RECTANGLE2)
            {
                cc = new Rectangle2CoordinateCalculator();
            }
            else if (mesh == MeshType.TILED_RECTANGLE1)
            {
                cc = new TiledRectangle1CoordinateCalculator();
            }
            else if (mesh == MeshType.RECTANGLE_SQUARE)
            {
                cc = new RectangleSquareCoordinateCalculator();
            }
            else if (mesh == MeshType.SQUARE_TRIANGLE1)
            {
                cc = new SquareTriangle1CoordinateCalculator();
            }
            else if (mesh == MeshType.SQUARE_TRIANGLE2)
            {
                cc = new SquareTriangle1CoordinateCalculator();
            }
            else if (mesh == MeshType.HEXAGON_TRIANGLE1)
            {
                cc = new HexagonTriangleCoordinateCalculator();
            }
            else if (mesh == MeshType.OCTOGON_SQUARE)
            {
                cc = new SquareCoordinateCalculator();
            }
            else if (mesh == MeshType.DODECAGON_TRIANGLE)
            {
                cc = new HexagonTriangleCoordinateCalculator();
            }
            else if (mesh == MeshType.HEXAGON_TRIANGLE2)
            {
                cc = new HexagonTriangle2CoordinateCalculator();
            }
            else if (mesh == MeshType.HEXAGON_SQUARE_TRIANGLE)
            {
                cc = new HexagonSquareTriangleCoordinateCalculator();
            }
            else if (mesh == MeshType.DODECAGON_HEXAGON_SQUARE)
            {
                cc = new HexagonSquareTriangleCoordinateCalculator();
            }
            return(cc);
        }