Exemplo n.º 1
0
        // path should contain only polylines ( use Flatten )
        // furthermore the constructor assumes that all Subpathes of path except the first one are holes
        public Polygon(GraphicsPath path)
        {
            NofContours = 0;
            foreach (byte b in path.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 < path.PathPoints.Length; i++)
            {
                contour.Add(path.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();
                }
            }
        }
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
 public Polygon(VertexList contour, bool contourIsHole)
 {
     this.AddContour(contour, contourIsHole);
 }
        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;
        }
        // path should contain only polylines ( use Flatten )
        // furthermore the constructor assumes that all Subpathes of path except the first one are holes
        public Polygon( GraphicsPath path )
        {
            NofContours = 0;
            foreach ( byte b in path.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<path.PathPoints.Length ; i++ ) {
                contour.Add( path.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();
                }
            }
        }