Esempio n. 1
0
        public void SortForTenGonFor7PointsBelow()
        {
            Polygon Unsorted = new Polygon();
            Polygon Sorted   = new Polygon();

            Sorted.AddPoint(new XYPT(-3, -1));
            Sorted.AddPoint(new XYPT(-2, -2));
            Sorted.AddPoint(new XYPT(-1, -3));
            Sorted.AddPoint(new XYPT(0, -4));
            Sorted.AddPoint(new XYPT(1, -3));
            Sorted.AddPoint(new XYPT(2, -2));
            Sorted.AddPoint(new XYPT(3, -1));
            Sorted.AddPoint(new XYPT(4, 2));
            Sorted.AddPoint(new XYPT(0, 6));
            Sorted.AddPoint(new XYPT(-4, 2));

            Unsorted.AddPoint(new XYPT(0, -4));
            Unsorted.AddPoint(new XYPT(-2, -2));
            Unsorted.AddPoint(new XYPT(-1, -3));
            Unsorted.AddPoint(new XYPT(-3, -1));
            Unsorted.AddPoint(new XYPT(3, -1));
            Unsorted.AddPoint(new XYPT(2, -2));
            Unsorted.AddPoint(new XYPT(0, 6));
            Unsorted.AddPoint(new XYPT(-4, 2));
            Unsorted.AddPoint(new XYPT(1, -3));
            Unsorted.AddPoint(new XYPT(4, 2));

            Unsorted.SortPoints();

            for (int i = 0; i < Unsorted.Count; i++)
            {
                Assert.AreEqual(Sorted.Points[i], Unsorted.Points[i]);
            }
        }
Esempio n. 2
0
 void Monitor_DrawSquare(object sender, MonitorDrawSquareEventArgs e)
 {
     if (CurrentState == QtreeEditorState.Edit)
     {
         if (!Directory.Exists(QtreeFullPath))
         {
             return;
         }
         var points = new List <PointF>
         {
             new PointF((float)e.Bounds.Left, (float)e.Bounds.Top),
             new PointF((float)e.Bounds.Right, (float)e.Bounds.Top),
             new PointF((float)e.Bounds.Right, (float)e.Bounds.Bottom),
             new PointF((float)e.Bounds.Left, (float)e.Bounds.Bottom),
             new PointF((float)e.Bounds.Left, (float)e.Bounds.Top)
         };
         DrawPolygon(points);
     }
     else if (CurrentState == QtreeEditorState.CreatingQtree)
     {
         NewQtreeBounds = e.Bounds;
         var pol = new Polygon("square", StyleFactory.GetPolygonFromColor(Color.Red, Color.DarkRed));
         pol.AddPoint(new Point("0", e.Bounds.Left, e.Bounds.Top));
         pol.AddPoint(new Point("1", e.Bounds.Right, e.Bounds.Top));
         pol.AddPoint(new Point("2", e.Bounds.Right, e.Bounds.Bottom));
         pol.AddPoint(new Point("3", e.Bounds.Left, e.Bounds.Bottom));
         pol.AddPoint(new Point("4", e.Bounds.Left, e.Bounds.Top));
         Monitor.AddGeometries(LayerGeocercas, pol);
     }
 }
        /// <summary>
        /// 鼠标移动时运行
        /// </summary>
        /// <param name="movePT">鼠标地图点</param>
        public void OnMouseMoveRun(IPoint movePT)
        {
            if (polygonFeedback != null)
            {
                polygonFeedback.MoveTo(movePT);
            }
            // 点集合
            IPointCollection pointColTemp = new Polygon();

            for (int i = 0; i < pointCollection.PointCount; i++)
            {
                pointColTemp.AddPoint(pointCollection.get_Point(i), Type.Missing, Type.Missing);
            }
            // 添加当前点
            pointColTemp.AddPoint(movePT);
            if (pointColTemp.PointCount < 3)
            {
                return;
            }
            // 获得图形
            IPolygon polygon = pointColTemp as IPolygon;

            if (polygon != null)
            {
                polygon.Close();
                IGeometry            geo  = polygon as IGeometry;
                ITopologicalOperator topo = geo as ITopologicalOperator;
                topo.Simplify();
                geo.Project(mapControl.SpatialReference);
                // 获得面积
                IArea area = geo as IArea;
                totalArea = area.Area;
            }
        }
Esempio n. 4
0
        private IPolygon BuildRectange(IPoint centerPt)
        {
            double fwWidth  = 0;
            double fwHeight = 0;

            fwWidth  = CountFilmWindowWidth();
            fwHeight = fwWidth / _WidthHeightRatio;

            IPointCollection ptCol = new Polygon();

            IPoint pts_0 = new ESRI.ArcGIS.Geometry.Point();

            pts_0.PutCoords(centerPt.X - fwWidth / 2, centerPt.Y - fwHeight / 2);
            IPoint pts_1 = new ESRI.ArcGIS.Geometry.Point();

            pts_1.PutCoords(centerPt.X - fwWidth / 2, centerPt.Y + fwHeight / 2);
            IPoint pts_2 = new ESRI.ArcGIS.Geometry.Point();

            pts_2.PutCoords(centerPt.X + fwWidth / 2, centerPt.Y + fwHeight / 2);
            IPoint pts_3 = new ESRI.ArcGIS.Geometry.Point();

            pts_3.PutCoords(centerPt.X + fwWidth / 2, centerPt.Y - fwHeight / 2);

            ptCol.AddPoint(pts_0);
            ptCol.AddPoint(pts_1);
            ptCol.AddPoint(pts_2);
            ptCol.AddPoint(pts_3);
            ptCol.AddPoint(pts_0);

            return(ptCol as IPolygon);
        }
        /// <summary>
        /// Create the inner polygon of the doughnut.
        /// </summary>
        /// <param name="_value">double</param>
        /// <param name="_sumDegree">double</param>
        /// <param name="_color">Color</param>
        /// <param name="_degree">double</param>
        private void CreateInnerSection(double _value, ref double _sumDegree, Color _color, out double _degree)
        {
            SVGPoint  p1 = null, p2 = null;
            Polygon   pol    = null;
            ArrayList points = null;

            _degree = this.Relation * _value;

            if (_sumDegree >= 270 || _sumDegree <= 90 || _degree + _sumDegree >= 270 || _degree + _sumDegree <= 90)
            {
                pol       = new Polygon();
                pol.Color = _color;
                points    = new ArrayList();

                double k = _sumDegree;
                while (k < _degree + _sumDegree)
                {
                    p1 = this.GetPoint(k, this.a2, this.b2);
                    pol.AddPoint(p1);
                    p2    = p1;
                    p2.Y += THICKNESS;
                    points.Insert(0, p2);
                    k += 0.2;
                }

                foreach (SVGPoint point in points)
                {
                    pol.AddPoint(point);
                }
                this.Doc.SvgObjects.Add(pol);
            }

            _sumDegree += _degree;
        }
Esempio n. 6
0
        /// <summary>
        /// Creates the polygon's value
        /// </summary>
        /// <param name="_value">double</param>
        /// <param name="_sumDegree">double</param>
        /// <param name="_color">Color</param>
        /// <param name="_degree">double</param>
        protected virtual void CreateCheese(double _value, ref double _sumDegree, Color _color, out double _degree)
        {
            SVGPoint point;
            Polygon  pol = new Polygon();

            pol.Color = _color;
            _degree   = this.Relation * _value;

            //1st Segment
            point = this.GetPoint(_sumDegree);
            pol.AddPoint(this.CenterPos);
            pol.AddPoint(point);

            //Curve
            double k = _sumDegree;

            while (k < _degree + _sumDegree)
            {
                pol.AddPoint(this.GetPoint(k));
                k += 0.2;
            }

            //2th Segment
            _sumDegree += _degree;
            point       = this.GetPoint(_sumDegree);
            pol.AddPoint(this.CenterPos);
            pol.AddPoint(point);

            this.Doc.SvgObjects.Add(pol);
        }
Esempio n. 7
0
    static private Slice2D SlicePolygonInside(Polygon polygon, List <Vector2f> slice)    // Create Polygon Inside?
    {
        Slice2D result = Slice2D.Create();

        Polygon newPoly = new Polygon();

        bool createPoly = false;

        foreach (Pair2f pairA in Pair2f.GetList(slice, false))
        {
            foreach (Pair2f pairB in Pair2f.GetList(slice, false))
            {
                Vector2f intersection = MathHelper.GetPointLineIntersectLine(pairA, pairB);
                if (intersection != null && (pairA.A != pairB.A && pairA.B != pairB.B && pairA.A != pairB.B && pairA.B != pairB.A))
                {
                    createPoly = !createPoly;
                    newPoly.AddPoint(intersection);
                }
            }
            if (createPoly == true)
            {
                newPoly.AddPoint(pairA.B);
            }
        }

        bool inHoles = false;

        foreach (Polygon hole in polygon.holesList)
        {
            if (hole.PolyInPoly(newPoly) == true)
            {
                inHoles = true;
            }
        }

        if (inHoles == false && newPoly.pointsList.Count > 2 && polygon.PolyInPoly(newPoly) == true)
        {
            polygon.AddHole(newPoly);
            List <Polygon> polys = new List <Polygon> (polygon.holesList);
            foreach (Polygon hole in polys)
            {
                if (newPoly.PolyInPoly(hole) == true)
                {
                    polygon.holesList.Remove(hole);
                    newPoly.AddHole(hole);
                }
            }

            result.AddPolygon(polygon);
            if (Slicer2D.complexSliceType == Slicer2D.SliceType.FillSlicedHole)
            {
                result.AddPolygon(newPoly);
            }

            return(result);
        }

        return(result);
    }
Esempio n. 8
0
        protected override void OnMouseDown(MouseEventArgs arg)
        {
            IMxDocument pMxDoc  = ArcMap.Application.Document as IMxDocument;
            IRubberBand pRubber = new RubberPolygon();
            IPolygon    pPolygon;
            // IPolygon pPolygon = pRubber.TrackNew(pMxDoc.ActiveView.ScreenDisplay, null) as IPolygon;



            IPoint pPoint1 = new Point();

            pPoint1.X = -2140489.683;
            pPoint1.Y = 33264366.694;

            IPoint pPoint2 = new Point();

            pPoint2.X = 19727215.727;
            pPoint2.Y = 27942068.023;

            IPoint pPoint3 = new Point();

            pPoint3.X = 30400767.253;
            pPoint3.Y = 14570156.281;



            IPointCollection pPointCollection = new Polygon();

            pPointCollection.AddPoint(pPoint1);
            pPointCollection.AddPoint(pPoint2);
            pPointCollection.AddPoint(pPoint3);
            pPointCollection.AddPoint(pPoint1);

            pPolygon = pPointCollection as IPolygon;

            IArea pArea = pPolygon as IArea;

            if (pArea.Area < 0)
            {
                pPolygon.ReverseOrientation();
            }

            IFeatureLayer  pFLayer = pMxDoc.FocusMap.Layer[0] as IFeatureLayer;
            IDataset       pDS     = pFLayer.FeatureClass as IDataset;
            IWorkspaceEdit pWSE    = pDS.Workspace as IWorkspaceEdit;

            pWSE.StartEditing(false);
            pWSE.StartEditOperation();

            IFeature pFeature = pFLayer.FeatureClass.CreateFeature();

            pFeature.Shape = pPolygon;
            pFeature.Store();
            pWSE.StopEditOperation();
            pWSE.StopEditing(true);

            pMxDoc.ActiveView.Refresh();
        }
Esempio n. 9
0
        /// <summary>
        /// Creates the polygon's value
        /// </summary>
        /// <param name="_value">double</param>
        /// <param name="_sumDegree">double</param>
        /// <param name="_color">Color</param>
        /// <param name="_degree">double</param>
        protected override void CreateCheese(double _value, ref double _sumDegree, Color _color, out double _degree)
        {
            double    k;
            ArrayList points = null;
            SVGPoint  p1, p2;
            Polygon   pol1;
            Polygon   pol2 = null;

            _degree = this.Relation * _value;

            pol1       = new Polygon();
            pol1.Color = _color;

            //1st Segment
            p1 = this.GetPoint(_sumDegree);
            pol1.AddPoint(this.CenterPos);
            pol1.AddPoint(p1);

            //Curve
            k = _sumDegree;
            if ((_sumDegree >= 90 && _sumDegree <= 270) || (_degree + _sumDegree >= 90 && _degree + _sumDegree <= 270))
            {
                pol2       = new Polygon();
                pol2.Color = _color;
                points     = new ArrayList();
                p1         = this.GetPoint(k);
            }
            while (k < _degree + _sumDegree)
            {
                p1 = this.GetPoint(k);
                pol1.AddPoint(p1);
                k += 0.2;

                if (k > 90 && k < 270)
                {
                    pol2.AddPoint(p1);
                    p2    = p1;
                    p2.Y += THICKNESS;
                    points.Insert(0, p2);
                }
            }
            if (pol2 != null)
            {
                foreach (SVGPoint point in points)
                {
                    pol2.AddPoint(point);
                }
                this.Doc.SvgObjects.Add(pol2);
            }

            //2th Segment
            _sumDegree += _degree;
            pol1.AddPoint(this.CenterPos);

            this.Doc.SvgObjects.Add(pol1);
        }
Esempio n. 10
0
        private Polygon TriToPoly(Triangle triangle)
        {
            var poly = new Polygon();

            poly.AddPoint(new PolygonPoint(triangle.A.Vector[0], triangle.A.Vector[1]));
            poly.AddPoint(new PolygonPoint(triangle.B.Vector[0], triangle.B.Vector[1]));
            poly.AddPoint(new PolygonPoint(triangle.C.Vector[0], triangle.C.Vector[1]));

            return(poly);
        }
Esempio n. 11
0
    public static Polygon MakeSquare(float sideLength)
    {
        Polygon square = new Polygon();

        square.AddPoint(new Vector2(-.5f, -.5f));
        square.AddPoint(new Vector2(+.5f, -.5f));
        square.AddPoint(new Vector2(+.5f, +.5f));
        square.AddPoint(new Vector2(-.5f, +.5f));
        square.Scale(sideLength);

        return(square);
    }
Esempio n. 12
0
        public void PointInPolygontopleft()
        {
            XYPT    point4 = new XYPT(-2, 2);
            Polygon big    = new Polygon();

            big.AddPoint(new XYPT(-2, -2));
            big.AddPoint(new XYPT(2, -2));
            big.AddPoint(new XYPT(2, 2));
            big.AddPoint(new XYPT(-2, 2));

            Assert.AreEqual(true, big.PointInPolygon(point4));
        }
Esempio n. 13
0
    static private Polygon CreateFromBoxCollider(BoxCollider2D boxCollider)
    {
        Polygon newPolygon = new Polygon();

        Vector2 size = new Vector2(boxCollider.size.x / 2, boxCollider.size.y / 2);

        newPolygon.AddPoint(new Vector2(-size.x, -size.y) + boxCollider.offset);
        newPolygon.AddPoint(new Vector2(-size.x, size.y) + boxCollider.offset);
        newPolygon.AddPoint(new Vector2(size.x, size.y) + boxCollider.offset);
        newPolygon.AddPoint(new Vector2(size.x, -size.y) + boxCollider.offset);

        return(newPolygon);
    }
Esempio n. 14
0
        public Polygon GetPolygon(QLeaf leaf)
        {
            var id = GetPolygonId(leaf.Index.Y, leaf.Index.X);

            var pol = new Polygon(id, GetColor(leaf.Valor, leaf.Locked));

            pol.AddPoint(new Point("0", leaf.Posicion.Longitud, leaf.Posicion.Latitud));
            pol.AddPoint(new Point("1", leaf.Posicion.Longitud + HorizontalResolution, leaf.Posicion.Latitud));
            pol.AddPoint(new Point("2", leaf.Posicion.Longitud + HorizontalResolution, leaf.Posicion.Latitud - VerticalResolution));
            pol.AddPoint(new Point("3", leaf.Posicion.Longitud, leaf.Posicion.Latitud - VerticalResolution));
            pol.AddPoint(new Point("4", leaf.Posicion.Longitud, leaf.Posicion.Latitud));
            return(pol);
        }
Esempio n. 15
0
        public void PointMustBeInPolygonLineTop()
        {
            XYPT    point4 = new XYPT(21, 40);
            Polygon big    = new Polygon();

            big.AddPoint(new XYPT(20, 20));
            big.AddPoint(new XYPT(40, 20));
            big.AddPoint(new XYPT(40, 40));
            big.AddPoint(new XYPT(20, 40));


            Assert.AreEqual(true, big.PointInPolygon(point4));
        }
Esempio n. 16
0
        public void PointInPolygon()
        {
            XYPT point1 = new XYPT(1.999999999, 1.999999999);

            Polygon big = new Polygon();

            big.AddPoint(new XYPT(-2, -2));
            big.AddPoint(new XYPT(2, -2));
            big.AddPoint(new XYPT(2, 2));
            big.AddPoint(new XYPT(-2, 2));

            Assert.AreEqual(true, big.PointInPolygon(point1));
        }
Esempio n. 17
0
        public void PointMustNotBeInPolygonTriangle()
        {
            XYPT point4 = new XYPT(20, 0);

            Polygon big = new Polygon();

            big.AddPoint(new XYPT(20, 20));
            big.AddPoint(new XYPT(180, 0));
            big.AddPoint(new XYPT(80, 120));


            Assert.AreNotEqual(true, big.PointInPolygon(point4));
        }
Esempio n. 18
0
        public void PointInPolygonbotright()
        {
            XYPT point2 = new XYPT(2, -2);

            Polygon big = new Polygon();

            big.AddPoint(new XYPT(-2, -2));
            big.AddPoint(new XYPT(2, -2));
            big.AddPoint(new XYPT(2, 2));
            big.AddPoint(new XYPT(-2, 2));

            Assert.AreEqual(true, big.PointInPolygon(point2));
        }
Esempio n. 19
0
        public void SortForOctagon()
        {
            Polygon Unsorted = new Polygon();
            Polygon Sorted   = new Polygon();

            Sorted.AddPoint(new XYPT(-2, 1));
            Sorted.AddPoint(new XYPT(-1, 0));
            Sorted.AddPoint(new XYPT(1, 0));
            Sorted.AddPoint(new XYPT(2, 1));
            Sorted.AddPoint(new XYPT(2, 2));
            Sorted.AddPoint(new XYPT(1, 3));
            Sorted.AddPoint(new XYPT(-1, 3));
            Sorted.AddPoint(new XYPT(-2, 2));

            Unsorted.AddPoint(new XYPT(1, 0));
            Unsorted.AddPoint(new XYPT(-1, 0));
            Unsorted.AddPoint(new XYPT(2, 1));
            Unsorted.AddPoint(new XYPT(1, 3));
            Unsorted.AddPoint(new XYPT(-2, 1));
            Unsorted.AddPoint(new XYPT(2, 2));
            Unsorted.AddPoint(new XYPT(-1, 3));
            Unsorted.AddPoint(new XYPT(-2, 2));

            Unsorted.SortPoints();

            for (int i = 0; i < Unsorted.Count; i++)
            {
                Assert.AreEqual(Sorted.Points[i], Unsorted.Points[i]);
            }
        }
Esempio n. 20
0
        /// <summary>
        /// </summary>
        /// <param name="direction"></param>
        /// <param name="transformation"></param>
        public void Transform(esriTransformDirection direction, ITransformation transformation)
        {
            object           value        = Missing.Value;
            IPointCollection polygonClass = new Polygon();

            polygonClass.AddPoint(this.m_pGeometry.LowerLeft, ref value, ref value);
            polygonClass.AddPoint(this.m_pGeometry.LowerRight, ref value, ref value);
            polygonClass.AddPoint(this.m_pGeometry.UpperRight, ref value, ref value);
            polygonClass.AddPoint(this.m_pGeometry.UpperLeft, ref value, ref value);
            (polygonClass as IPolygon).Close();
            (polygonClass as IGeometry).SpatialReference = this.m_pGeometry.SpatialReference;
            (polygonClass as ITransform2D).Transform(direction, transformation);
            this.m_pGeometry = (polygonClass as IPolygon).Envelope;
            this.RefreshTracker();
        }
        /// <summary>
        /// Get the Polygon for the side of the bar
        /// </summary>
        /// <param name="_bar">Rectangle</param>
        /// <param name="_indexRow">int</param>
        /// <returns>Polygon</returns>
        private Polygon GenerateSidePol(Rectangle _bar, int _indexRow)
        {
            double yBottom = _bar.Y - this.depth * Math.Sign(ANGLE);
            double xBottom = _bar.X + this.depth * Math.Cos(ANGLE);

            Polygon pol = new Polygon();

            pol.Color = this.Colors[_indexRow];
            pol.AddPoint(_bar.X + _bar.Width, _bar.Y);
            pol.AddPoint(xBottom + _bar.Width, yBottom);
            pol.AddPoint(xBottom + _bar.Width, yBottom + _bar.Height);
            pol.AddPoint(_bar.X + _bar.Width, _bar.Y + _bar.Height);

            return(pol);
        }
 public void Setup()
 {
     TESTPOLYGON = new Polygon("TESTPOLYGON");
     TESTPOLYGON.AddPoint(new VertexPositionColor(new Vector3(-7f, 0, 1f), Color.Red));
     TESTPOLYGON.AddPoint(new VertexPositionColor(new Vector3(-2, 0, 4), Color.Red));
     TESTPOLYGON.AddPoint(new VertexPositionColor(new Vector3(5, 0, 4), Color.Red));
     TESTPOLYGON.AddPoint(new VertexPositionColor(new Vector3(0, 0, 0), Color.Red));
     TESTPOLYGON.AddPoint(new VertexPositionColor(new Vector3(-2, 0, 2), Color.Red));
     CircleList = new List <Circle>();
     CircleList.Add(new Circle(new Vector2(-6, 4), 2f));  //Poza 0
     CircleList.Add(new Circle(new Vector2(-2, 0), 2f));  //Kolizja 1
     CircleList.Add(new Circle(new Vector2(0, 2), 1f));   //W polygonie 2
     CircleList.Add(new Circle(new Vector2(6, 4), 5.0f)); //kolizja 3
     CircleList.Add(new Circle(new Vector2(0, 6), 1.0f)); //Brak kolizji 4
 }
Esempio n. 23
0
        public void TestAddPointOutOfRange()
        {
            MainForm m = new MainForm();
            Polygon  p = new Polygon(m.pictureBox);

            p.AddPoint(55000, 15);
        }
Esempio n. 24
0
        public void TestOutOfRangeAddPointY()
        {
            MainForm mf = new MainForm();
            Polygon  p  = new Polygon(mf.pictureBox);

            p.AddPoint(5, 56000);
        }
Esempio n. 25
0
    static private Polygon CreateFromPolygonCollider(PolygonCollider2D polygonCollider)
    {
        Polygon newPolygon = new Polygon();

        if (polygonCollider != null)
        {
            foreach (Vector2 p in polygonCollider.GetPath(0))
            {
                newPolygon.AddPoint(p + polygonCollider.offset);
            }

            for (int i = 1; i < polygonCollider.pathCount; i++)
            {
                Polygon hole = new Polygon();
                foreach (Vector2 p in polygonCollider.GetPath(i))
                {
                    hole.AddPoint(p + polygonCollider.offset);
                }

                if (newPolygon.PolyInPoly(hole) == true)
                {
                    newPolygon.AddHole(hole);
                }
                else
                {
                    Debug.LogError("Path is not a hole");
                }
            }
        }
        return(newPolygon);
    }
Esempio n. 26
0
        /// <summary>
        /// Adds a polygonal geocerca.
        /// </summary>
        /// <param name="points"></param>
        protected void AddPolygon(List <PointF> points)
        {
            monitor.ClearLayer(LayerAreasPoi);

            if (points == null || points.Count == 0)
            {
                return;
            }

            var poly = new Polygon("POLYGON", StyleFactory.GetPointFromColor(Color));

            for (var i = 0; i < points.Count; i++)
            {
                poly.AddPoint(new Point(i.ToString("#0"), points[i].X, points[i].Y));
            }

            monitor.AddGeometries(LayerAreasPoi, poly);

            if (Direccion == null)
            {
                var lat = points.Average(p => p.Y);
                var lon = points.Average(p => p.X);
                SetCenter(lat, lon);
            }
        }
Esempio n. 27
0
    // Get List Of Polygons from Collider (Usually Used Before Creating Slicer2D Object)
    static public List <Polygon> GetListFromCollider(GameObject gameObject)
    {
        List <Polygon>    result          = new List <Polygon> ();
        PolygonCollider2D polygonCollider = gameObject.GetComponent <PolygonCollider2D> ();

        if (polygonCollider != null && polygonCollider.pathCount > 1)
        {
            Polygon newPolygon = new Polygon();

            foreach (Vector2 p in polygonCollider.GetPath(0))
            {
                newPolygon.AddPoint(p + polygonCollider.offset);
            }

            result.Add(newPolygon.ToWorldSpace(gameObject.transform));

            for (int i = 1; i < polygonCollider.pathCount; i++)
            {
                Polygon hole = new Polygon();
                foreach (Vector2 p in polygonCollider.GetPath(i))
                {
                    hole.AddPoint(p + polygonCollider.offset);
                }

                if (newPolygon.PolyInPoly(hole) == false)
                {
                    result.Add(hole.ToWorldSpace(gameObject.transform));
                }
            }
        }
        return(result);
    }
Esempio n. 28
0
        private void AddPolygon(string verticesData, int lineIndex)
        {
            var data    = verticesData.Split(Properties.MapFileSeparator);
            var polygon = new Polygon();

            //data must be even in order for everything to be properly initialized
            Assert.IsTrue(data.Length % 2 == 0);

            for (var i = 0; i < data.Length; i += 2)
            {
                var x = float.Parse(data[i]);
                var y = float.Parse(data[i + 1]);
                polygon.AddPoint(new Vector2(x, y));
            }

            if (lineIndex != 0)
            {
                polygon.EnsureWindingOrder(Properties.InnerPolygonWinding);
            }
            else
            {
                polygon.EnsureWindingOrder(Properties.OuterPolygonWinding);
            }

            Polygons.Add(polygon);
        }
Esempio n. 29
0
        protected override void UpdateData()
        {
            Word.Polygons.Clear();
            var solidFigure = Figure as SolidFigure;

            if (solidFigure == null)
            {
                throw new ArgumentNullException();
            }

            foreach (Figure figure in Figures)
            {
                PointF[] points  = figure.Path.PathPoints;
                var      polygon = new Polygon();

                foreach (PointF point in points)
                {
                    polygon.AddPoint(new DataBase.Domain.Point {
                        X = point.X, Y = point.Y
                    });
                }

                Word.AddPolygon(polygon);
            }
        }
Esempio n. 30
0
    //切り枠を発動
    private void PolygonSlice()
    {
        Polygon    newPolygon = new Polygon();
        GameObject Photo1     = GameObject.Find("Photo1");
        Vector2f   pos        = new Vector2f(Photo1.transform.position.x, Photo1.transform.position.y);//-40f -15f

        newPolygon.AddPoint(-Photo1.GetComponent <BoxCollider2D>().size.x / 2, Photo1.GetComponent <BoxCollider2D>().size.y / 2);
        newPolygon.AddPoint(Photo1.GetComponent <BoxCollider2D>().size.x / 2, Photo1.GetComponent <BoxCollider2D>().size.y / 2);
        newPolygon.AddPoint(Photo1.GetComponent <BoxCollider2D>().size.x / 2, -Photo1.GetComponent <BoxCollider2D>().size.y / 2);
        newPolygon.AddPoint(-Photo1.GetComponent <BoxCollider2D>().size.x / 2, -Photo1.GetComponent <BoxCollider2D>().size.y / 2);

        Polygon slicePolygonDestroy = null;

        Slicer2D.PolygonSliceAll(pos, newPolygon, slicePolygonDestroy, sliceLayer);
        HideDeleteFrame();
    }
        // the constructor for the Feature Class Management class
        public GoogleMapsEngineFeatureClassManagement(MapsEngine.API.GoogleMapsEngineAPI api)
        {
            // initialize and configure log4net, reading from Xml .config file
            log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));

            log.Info("GoogleMapsEngineFeatureClassManagement initializing.");

            // retrieve a reference to the extension
            log.Debug("Retrieiving a reference to the extension object.");
            ext = GoogleMapsEngineToolsExtensionForArcGIS.GetExtension();

            // initiate the Google Maps Enigne API object
            log.Debug("Setting the GME API object.");
            this.api = api;

            // generate a worldwide polygon, for default (spatial geometry undetermined or undefined) assets
            log.Debug("Establishing a default worldwide polygon object.");
            IPoint pUL = new Point();
            pUL.X = -180;
            pUL.Y = 90;
            IPoint pLL = new Point();
            pLL.X = -180;
            pLL.Y = -90;
            IPoint pLR = new Point();
            pLR.X = 180;
            pLR.Y = -90;
            IPoint pUR = new Point();
            pUR.X = 180;
            pUR.Y = 90;

            // add the points to the point collection
            IPointCollection pPtColl = new Polygon();
            pPtColl.AddPoint(pUL, Type.Missing, Type.Missing);
            pPtColl.AddPoint(pUR, Type.Missing, Type.Missing);
            pPtColl.AddPoint(pLR, Type.Missing, Type.Missing);
            pPtColl.AddPoint(pLL, Type.Missing, Type.Missing);
            pPtColl.AddPoint(pUL, Type.Missing, Type.Missing);

            // define the polygon as a list of points, then close the polygon
            worldPolygon = (IPolygon)pPtColl;
            worldPolygon.Close();
        }
Esempio n. 32
0
    // dessine un arc de cercle defini par les parametres de point auquel on applique une transformation de matrix
    // le pas de l'arc de cercle est defini par ANGLE_STEP en degré
    public static void Draw(ArchedPoint2 point, Matrix4x4 matrix,
		float offsetWidth=0, float offsetHeight=0)
    {
        Vector2 center = point.GetCenter ();
        float radius = point.GetMeasuredRadius ();

        Vector2 prevTangentPoint = point.GetPrevTangentPoint ();
        Vector2 nextTangentPoint = point.GetNextTangentPoint ();

        Vector2 firstPoint2Add = prevTangentPoint;
        Vector2 lastPoint2Add = nextTangentPoint;

        Vector2 startVector = (prevTangentPoint - center).normalized;
        Vector2 endVector = (nextTangentPoint - center).normalized;

        Vector2 angleMeasureReference = Vector2.right;

        if (point.GetAngleType () == AngleType.Outside)
        {
            startVector = (nextTangentPoint - center).normalized;
            endVector = (prevTangentPoint - center).normalized;

            firstPoint2Add = nextTangentPoint;
            lastPoint2Add = prevTangentPoint;
        }

        // On cherche les angles de depart et de fin par rapport au vector (1, 0)
        // pour tracer l'arc dans le sens trigonometrique
        float startAngle;
        if (Utils.Approximately (Vector3.Cross (startVector, angleMeasureReference).z, 0))
        {
            startAngle = Vector2.Dot (startVector, angleMeasureReference) < 0 ? 180 : 0;
        }
        else
        {
            Quaternion startRotation = Quaternion.FromToRotation (angleMeasureReference, startVector);
            startAngle = startRotation.eulerAngles.z;
        }

        float endAngle;
        if (Utils.Approximately (Vector3.Cross (endVector, angleMeasureReference).z, 0))
        {
            endAngle = Vector2.Dot (endVector, angleMeasureReference) < 0 ? 180 : 0;
        }
        else
        {
            Quaternion endRotation = Quaternion.FromToRotation (angleMeasureReference, endVector);
            endAngle = endRotation.eulerAngles.z;
        }

        //Debug.Log (startAngle + " " + endAngle);

        if (startAngle > endAngle)
        {
            endAngle += 360;
        }

        startAngle += ANGLE_STEP;
        float currentAngle = startAngle;

        // on cree le polygon ouvert correspondant a l'arc de cercle
        Polygon arc = new Polygon ();
        arc.AddPoint (new Point2 (firstPoint2Add));

        // ajout de chaque point du polygone calcule a partir de l'angle courant
        while (currentAngle < endAngle)
        {
            float radAngle = currentAngle * Mathf.Deg2Rad;
            Vector2 arcPoint = new Vector2 (Mathf.Cos (radAngle), Mathf.Sin (radAngle)) * radius + center;

            arc.AddPoint (new Point2 (arcPoint));

            currentAngle += ANGLE_STEP;
        }

        arc.AddPoint (new Point2 (lastPoint2Add));

        //		arc = new Polygon ();
        //		foreach (Vector2 v in point.GetCurve ())
        //		{
        //			arc.AddPoint (new Point2 (v));
        //		}

        // on dessine l'ensemble des edges correspondant a l'arc de cercle
        foreach (Edge2 edge in arc.GetEdges ())
        {
            EdgeDrawer.Draw (edge, matrix,10, offsetWidth, offsetHeight );
        }

        //		Vector2 anchorPoint = matrix.MultiplyPoint (point.GetAnchorPoint ());
        //		GUI.Box (new Rect (anchorPoint.x - POINT_RADIUS / 2,
        //					       anchorPoint.y - POINT_RADIUS / 2,
        //					       POINT_RADIUS,
        //					       POINT_RADIUS), "", "selected point");

        // dessine les points tangents
        prevTangentPoint.Set(prevTangentPoint.x+offsetWidth,prevTangentPoint.y + offsetHeight);
        prevTangentPoint = matrix.MultiplyPoint (prevTangentPoint);
        GUI.Box (new Rect (prevTangentPoint.x - POINT_RADIUS / 2,
                           prevTangentPoint.y - POINT_RADIUS / 2,
                           POINT_RADIUS,
                           POINT_RADIUS), "", /*"selected point up"*/"arcpoint");

        nextTangentPoint.Set(nextTangentPoint.x+offsetWidth,nextTangentPoint.y + offsetHeight);
        nextTangentPoint = matrix.MultiplyPoint (nextTangentPoint);
        GUI.Box (new Rect (nextTangentPoint.x - POINT_RADIUS / 2,
                           nextTangentPoint.y - POINT_RADIUS / 2,
                           POINT_RADIUS,
                           POINT_RADIUS), "", /*"selected point up"*/"arcpoint");

        //		center = matrix.MultiplyPoint (center);
        //		GUI.Box (new Rect (center.x - POINT_RADIUS / 2,
        //					       center.y - POINT_RADIUS / 2,
        //					       POINT_RADIUS,
        //					       POINT_RADIUS), "", "selected point");
    }
        /*
         * A function to populate a referenced Feature Class (fc) with the contents of a Google Maps Engine map layer
         */
        protected void populateFCWithGoogleMapsEngineLayer(ref IFeatureClass fc, string mapId, string parentId, MapsEngine.DataModel.gme.MapLayer layer)
        {
            // create a new feature
            IFeature feature;

            log.Debug("Creating a feature for layer " + layer.id);

            // attempt to process the assets within a the layer
            try
            {
                // fetch the layer asset object from the API
                log.Debug("Fetching an asset object for the layer.");
                MapsEngine.DataModel.gme.Asset layerAsset = api.getAssetById(ext.getToken(), layer.id);

                // create a new feature
                log.Debug("Creating a new feature.");
                feature = fc.CreateFeature();

                // Update the values for this feature
                feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_CustomerId_Name), mapId.Split("-".ToCharArray())[0]);
                log.Debug(Properties.Resources.GeodatabaseUtilities_schema_CustomerId_Name + ": " + mapId.Split("-".ToCharArray())[0]);
                feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_AssetId_Name), layer.id);
                log.Debug(Properties.Resources.GeodatabaseUtilities_schema_AssetId_Name + ": " + layer.id);
                feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_MapAssetId_Name), mapId);
                log.Debug(Properties.Resources.GeodatabaseUtilities_schema_MapAssetId_Name + ": " + mapId);
                feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_AssetType_Name), layerAsset.type);
                log.Debug(Properties.Resources.GeodatabaseUtilities_schema_AssetType_Name + ": " + layerAsset.type);
                feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_AssetName_Name), layerAsset.name);
                log.Debug(Properties.Resources.GeodatabaseUtilities_schema_AssetName_Name + ": " + layerAsset.name);
                feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_ParentAssetId_Name), parentId);
                log.Debug(Properties.Resources.GeodatabaseUtilities_schema_ParentAssetId_Name + ": " + parentId);

                // attempt to set the description object
                try
                {
                    // set the layer description value (truncate if necessary)
                    feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_AssetDescription_Name)
                        , layerAsset.description.Length > 256
                        ? layerAsset.description.Substring(0, 252) + "..."
                        : layerAsset.description);
                    log.Debug(Properties.Resources.GeodatabaseUtilities_schema_AssetDescription_Name + ": " + layerAsset.description);
                }
                catch (System.Exception ex)
                {
                    // log warning
                    log.Warn(ex);
                }

                // verify the layer has a bbox and has two valid points
                if (layerAsset.bbox != null && layerAsset.bbox.Count() == 4)
                {
                    // deterine the maximum and minimum bounds of all layers within this map
                    // 0=West, 1=South, 2=East, 3=North
                    double XMAX = layerAsset.bbox[2];
                    log.Debug("XMAX: " + XMAX);
                    double YMAX = layerAsset.bbox[3];
                    log.Debug("YMAX: " + YMAX);
                    double XMIN = layerAsset.bbox[0];
                    log.Debug("XMIN: " + XMIN);
                    double YMIN = layerAsset.bbox[1];
                    log.Debug("YMIN: " + YMIN);

                    // determine the map extent based on the layers maximum extent
                    IPoint pExtentNE = new Point();
                    pExtentNE.X = XMAX;
                    pExtentNE.Y = YMAX;
                    IPoint pExtentSW = new Point();
                    pExtentSW.X = XMIN;
                    pExtentSW.Y = YMIN;
                    IPoint pExtentNW = new Point();
                    pExtentNW.X = XMIN;
                    pExtentNW.Y = YMAX;
                    IPoint pExtentSE = new Point();
                    pExtentSE.X = XMAX;
                    pExtentSE.Y = YMIN;

                    // define the polygon bounding box (NE/SW) as a point collection
                    IPointCollection pExtentPointCol = new Polygon();
                    pExtentPointCol.AddPoint(pExtentNE, Type.Missing, Type.Missing);
                    pExtentPointCol.AddPoint(pExtentSE, Type.Missing, Type.Missing);
                    pExtentPointCol.AddPoint(pExtentSW, Type.Missing, Type.Missing);
                    pExtentPointCol.AddPoint(pExtentNW, Type.Missing, Type.Missing);

                    // create a polygon, p, from the point collection, then close the polygon
                    IPolygon pExtent = (IPolygon)pExtentPointCol;
                    pExtent.Close();

                    // add the polygon, p, as the new feature's geometry
                    if (pExtent != null)
                    {
                        // set the shape geometry
                        log.Debug("Setting the feature's geometry as the polygon.");
                        feature.Shape = pExtent;
                    }
                    else
                    {
                        // set the feature's goemetry as the default world
                        log.Debug("Invalid spatial representation, setting feature goemtry as the world.");
                        feature.Shape = worldPolygon;
                    }
                }
                else
                {
                    // the layer does not have spatial information
                    log.Warn("Layer has no bbox information");
                    //feature.Shape = worldPolygon;
                }

                // Commit the new feature to fc
                log.Debug("Storing feature.");
                feature.Store();
            }
            catch (Exception ex)
            {
                // log the warning
                log.Warn(ex);
            }
        }
        /*
         * A function to populate a referenced FeatureClass (fc) with the contents of a Google Maps Engine map
         */
        public void populateFCWithGoogleMapsEngineMap(ref IFeatureClass fc, ref MapsEngine.DataModel.gme.Map map)
        {
            // create a feature object
            log.Debug("Creating a new Feature object to be used later in populating the FC.");
            IFeature feature = fc.CreateFeature();

            log.Debug("Creating feature for map " + map.id);

            // create a projectId value from the MapId
            String projectId = map.id.Split("-".ToCharArray())[0];

            // Update the values for this feature
            feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_CustomerId_Name), projectId);
            log.Debug(Properties.Resources.GeodatabaseUtilities_schema_CustomerId_Name + ": " + projectId);
            feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_AssetId_Name), map.id);
            log.Debug(Properties.Resources.GeodatabaseUtilities_schema_AssetId_Name + ": " + map.id);
            feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_MapAssetId_Name), map.id);
            log.Debug(Properties.Resources.GeodatabaseUtilities_schema_MapAssetId_Name + ": " + map.id);
            feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_AssetType_Name), "map");
            log.Debug(Properties.Resources.GeodatabaseUtilities_schema_AssetType_Name + ": " + "map");
            feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_AssetName_Name), map.name);
            log.Debug(Properties.Resources.GeodatabaseUtilities_schema_AssetName_Name + ": " + map.name);
            feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_ParentAssetId_Name), projectId);
            log.Debug(Properties.Resources.GeodatabaseUtilities_schema_ParentAssetId_Name + ": " + projectId);

            // attempt to set the description
            try
            {
                // attempt to set the feature description (truncating if necessary)
                feature.set_Value(fc.FindField(Properties.Resources.GeodatabaseUtilities_schema_AssetDescription_Name)
                    , map.description.Length > 256
                    ? map.description.Substring(0, 252) + "..."
                    : map.description);
                log.Debug(Properties.Resources.GeodatabaseUtilities_schema_AssetDescription_Name + ": " + map.description);
            }
            catch (System.Exception ex)
            {
                // warn
                log.Warn(ex);
            }

            // check to see if the bbox object is not null
            log.Debug("Adding spatial representation if available.");
            if (map.bbox != null && map.bbox.Count() == 4)
            {
                // deterine the maximum and minimum bounds of all layers within this map
                // 0=West, 1=South, 2=East, 3=North
                double XMAX = map.bbox[2];
                log.Debug("XMAX: " + XMAX);
                double YMAX = map.bbox[3];
                log.Debug("YMAX: " + YMAX);
                double XMIN = map.bbox[0];
                log.Debug("XMIN: " + XMIN);
                double YMIN = map.bbox[1];
                log.Debug("YMIN: " + YMIN);


                // determine the map extent based on the layers maximum extent
                IPoint pExtentNE = new Point();
                pExtentNE.X = XMAX;
                pExtentNE.Y = YMAX;
                IPoint pExtentSW = new Point();
                pExtentSW.X = XMIN;
                pExtentSW.Y = YMIN;
                IPoint pExtentNW = new Point();
                pExtentNW.X = XMIN;
                pExtentNW.Y = YMAX;
                IPoint pExtentSE = new Point();
                pExtentSE.X = XMAX;
                pExtentSE.Y = YMIN;

                // define the polygon bounding box (NE/SW) as a point collection
                log.Debug("Building polygon object.");
                IPointCollection pExtentPointCol = new Polygon();
                pExtentPointCol.AddPoint(pExtentNE, Type.Missing, Type.Missing);
                pExtentPointCol.AddPoint(pExtentSE, Type.Missing, Type.Missing);
                pExtentPointCol.AddPoint(pExtentSW, Type.Missing, Type.Missing);
                pExtentPointCol.AddPoint(pExtentNW, Type.Missing, Type.Missing);

                // create a polygon, p, from the point collection, then close the polygon
                IPolygon pExtent = (IPolygon)pExtentPointCol;
                pExtent.Close();

                // add the polygon, p, as the new feature's geometry
                if (pExtent != null)
                {
                    log.Debug("Setting feature's geometry.");
                    feature.Shape = pExtent;
                }
                else
                {
                    log.Warn("Polygon is not valid, setting feature geometry to default worldwide.");
                    feature.Shape = worldPolygon;
                }
            }
            else
            {
                // no spatial information contained, use world
                log.Warn("No spatial representation, setting feature geometry to default worldwide.");
                //feature.Shape = worldPolygon;
            }

            // Commit the new feature to fc
            log.Debug("Storing feature.");
            feature.Store();

            // add all child layers within this map
            log.Debug("Verifying the map has layers.");
            if (map.layers != null)
            {
                // go through each layer in the map
                log.Debug("Going through each layer in the map.");
                foreach (MapsEngine.DataModel.gme.MapLayer layer in map.layers)
                {
                    // populate the features in the layer
                    log.Debug("Processing layer " + layer.id);
                    populateFCWithGoogleMapsEngineLayer(ref fc, map.id, map.id, layer);
                }
            }

            // Verifying the map has a folders object
            log.Debug("Verifying the map has a folders object.");
            if (map.folders != null && map.folders.Count() > 0)
            {
                // populate the features in the folder
                log.Debug("Processing folders");
                populateFCWithGoogleMapsEngineFolders(ref fc, map.id, map.id, map.folders);
            }
        }
Esempio n. 35
0
        private IGeometry GetGeometry(int row, int column)
        {
            IPointCollection polygon = new Polygon();

            //Clockwise for filled, Counter-clockwise for holes
            polygon.AddPoint(LowerLeftPoint(row, column));
            polygon.AddPoint(UpperLeftPoint(row, column));
            polygon.AddPoint(UpperRightPoint(row, column));
            polygon.AddPoint(LowerRightPoint(row, column));
            polygon.AddPoint(LowerLeftPoint(row, column));

            //coordinates are defined in the map display
            ((IGeometry)polygon).SpatialReference = Map.SpatialReference;

            return (IGeometry)polygon;
        }
Esempio n. 36
0
        public static OpenGLShapeInfo ReadXml(System.Xml.XmlReader r)
        {
            var icult = System.Globalization.CultureInfo.InvariantCulture;

            var i = new OpenGLShapeInfo ();

            while (r.Read ()) {
                if (r.IsStartElement ("Info")) {
                    i.ShapeType = (OpenGLShapeType)Enum.Parse (typeof (OpenGLShapeType), r.GetAttribute ("ShapeType"));
                    i.A = float.Parse (r.GetAttribute ("A"), icult);
                    i.B = float.Parse (r.GetAttribute ("B"), icult);
                    i.C = float.Parse (r.GetAttribute ("C"), icult);
                    i.D = float.Parse (r.GetAttribute ("D"), icult);
                    i.Fill = r.GetAttribute ("Fill") == "true";
                    var ch = r.GetAttribute ("Char");
                    i.Char = string.IsNullOrEmpty (ch) ? (char)0 : ch[0];
                    var ff = r.GetAttribute ("FontFamily");
                    if (!string.IsNullOrWhiteSpace (ff)) {
                        var fw = r.GetAttribute ("FontWeight");
                        var fo = fw == "bold" ? FontOptions.Bold : FontOptions.None;
                        var fs = int.Parse (r.GetAttribute ("FontSize"), icult);
                        i.Font = new Font (ff, fo, fs);
                    }
                }
                else if (r.IsStartElement ("Polygon")) {
                    var parts = r.GetAttribute ("Points").Split (WS, StringSplitOptions.RemoveEmptyEntries);
                    var poly = new Polygon ();
                    for (var j = 0; j < parts.Length; j += 2) {
                        var p = new PointF (float.Parse (parts[j], icult), float.Parse (parts[j + 1], icult));
                        poly.AddPoint (p);
                    }
                    i.Poly = poly;
                }
                else if (r.IsStartElement ("Polyline")) {
                    var parts = r.GetAttribute ("Points").Split (WS, StringSplitOptions.RemoveEmptyEntries);
                    var poly = new List<PointF> ();
                    for (var j = 0; j < parts.Length; j += 2) {
                        var p = new PointF (float.Parse (parts[j], icult), float.Parse (parts[j + 1], icult));
                        poly.Add (p);
                    }
                    i.PolylinePoints = poly.ToArray ();
                    i.PolylineLength = i.PolylinePoints.Length;
                }
            }

            return i;
        }
Esempio n. 37
0
        public void Render(IGraphics g, OpenGLTextureReference tex)
        {
            g.SetColor (Colors.White);

            var x = tex.X + tex.ShapeOffset.X;
            var y = tex.Y + tex.ShapeOffset.Y;

            switch (ShapeType) {
            case OpenGLShapeType.Line:
                g.DrawLine (x, y, x + A, y + B, C);
                break;
            case OpenGLShapeType.Rect:
                if (Fill) {
                    g.FillRect (x, y, A, B);
                }
                else {
                    g.DrawRect (x, y, A, B, C);
                }
                break;
            case OpenGLShapeType.RoundedRect:
                if (Fill) {
                    g.FillRoundedRect (x, y, A, B, C);
                }
                else {
                    g.DrawRoundedRect (x, y, A, B, C, D);
                }
                break;
            case OpenGLShapeType.Oval:
                if (Fill) {
                    g.FillOval (x, y, A, B);
                }
                else {
                    g.DrawOval (x, y, A, B, C);
                }
                break;
            case OpenGLShapeType.Character:
                g.SetFont (Font);
                g.DrawString (Char.ToString (), x, y);
                break;
            case OpenGLShapeType.Polygon: {
                    var dx = x - Poly.Points[0].X;
                    var dy = y - Poly.Points[0].Y;
                    var dpoly = new Polygon ();
                    for (var i = 0; i < Poly.Points.Count; i++) {
                        dpoly.AddPoint (Poly.Points[i].X + dx, Poly.Points[i].Y + dy);
                    }
                    if (Fill) {
                        g.FillPolygon (dpoly);
                    }
                    else {
                        g.DrawPolygon (dpoly, A);
                    }
                }
                break;
            case OpenGLShapeType.Arc:
                if (Fill) {
                    g.FillArc (x, y, A, B, C);
                }
                else {
                    g.DrawArc (x, y, A, B, C, D);
                }
                break;
            case OpenGLShapeType.Polyline: {
                    var dx = x - PolylinePoints[0].X;
                    var dy = y - PolylinePoints[0].Y;
                    g.BeginLines (true);
                    for (var i = 0; i < PolylineLength - 1; i++) {
                        g.DrawLine (
                            PolylinePoints[i].X + dx,
                            PolylinePoints[i].Y + dy,
                            PolylinePoints[i + 1].X + dx,
                            PolylinePoints[i + 1].Y + dy,
                            A);
                    }
                    g.EndLines ();
                }
                break;
            default:
                throw new NotSupportedException ();
            }
        }