Exemplo n.º 1
0
        //мÓ
        public GpcPolygon(EasyMap.Geometries.Point[] pathPoints)
        {
            NofContours = 0;
            byte[] pathTypes = new byte[pathPoints.Length];
            //object pathTypes = pathPoints.GetType;
            //PointF[] pathPoints = points.PathPoints;
            for (int i = 0; i < pathPoints.Length; i++)
            {
                object type = pathPoints[i].GetType();
                if (i == 0)
                {
                    pathTypes[i] = 0;
                }
                else if (i == pathPoints.Length - 1)
                {
                    pathTypes[i] = 128;
                }
                else
                {
                    pathTypes[i] = 1;
                }
            }
            foreach (byte b in pathTypes)
            {
                if ((b & ((byte)PathPointType.CloseSubpath)) != 0)
                {
                    NofContours++;
                }
            }

            ContourIsHole = new bool[NofContours];
            Contour       = new VertexList[NofContours];
            for (int i = 0; i < NofContours; i++)
            {
                ContourIsHole[i] = (i == 0);
            }

            int       contourNr = 0;
            ArrayList contour   = new ArrayList();

            for (int i = 0; i < pathPoints.Length; i++)
            {
                contour.Add(pathPoints[i]);
                if ((pathTypes[i] & ((byte)PathPointType.CloseSubpath)) != 0)
                {
                    EasyMap.Geometries.Point[] pointArray = (EasyMap.Geometries.Point[])contour.ToArray(typeof(EasyMap.Geometries.Point));
                    VertexList vl = new VertexList(pointArray);
                    Contour[contourNr++] = vl;
                    contour.Clear();
                }
            }
        }
Exemplo n.º 2
0
        public void AddContour(VertexList contour, bool contourIsHole)
        {
            bool[]       hole = new bool[NofContours + 1];
            VertexList[] cont = new VertexList[NofContours + 1];

            for (int i = 0; i < NofContours; i++)
            {
                hole[i] = ContourIsHole[i];
                cont[i] = Contour[i];
            }
            hole[NofContours]   = contourIsHole;
            cont[NofContours++] = contour;

            ContourIsHole = hole;
            Contour       = cont;
        }
Exemplo n.º 3
0
        // path should contain only polylines ( use Flatten )
        // furthermore the constructor assumes that all Subpathes of path except the first one are holes
        public GpcPolygon(GraphicsPath path)
        {
            NofContours = 0;
            byte[]   pathTypes  = path.PathTypes;
            PointF[] pathPoints = path.PathPoints;

            foreach (byte b in pathTypes)
            {
                if ((b & ((byte)PathPointType.CloseSubpath)) != 0)
                {
                    NofContours++;
                }
            }

            ContourIsHole = new bool[NofContours];
            Contour       = new VertexList[NofContours];
            for (int i = 0; i < NofContours; i++)
            {
                ContourIsHole[i] = (i == 0);
            }

            int       contourNr = 0;
            ArrayList contour   = new ArrayList();

            for (int i = 0; i < pathPoints.Length; i++)
            {
                contour.Add(pathPoints[i]);
                if ((path.PathTypes[i] & ((byte)PathPointType.CloseSubpath)) != 0)
                {
                    PointF[]   pointArray = (PointF[])contour.ToArray(typeof(PointF));
                    VertexList vl         = new VertexList(pointArray);
                    Contour[contourNr++] = vl;
                    contour.Clear();
                }
            }
        }