コード例 #1
0
ファイル: geomWrapper.cs プロジェクト: jugstalt/gViewGisOS
        public GeomPolygon(IEnvelope envelope)
        {
            Polygon polygon = new Polygon();
            Ring    ring    = new Ring();

            ring.AddPoint(new gView.Framework.Geometry.Point(envelope.minx, envelope.miny));
            ring.AddPoint(new gView.Framework.Geometry.Point(envelope.minx, envelope.maxy));
            ring.AddPoint(new gView.Framework.Geometry.Point(envelope.maxx, envelope.maxy));
            ring.AddPoint(new gView.Framework.Geometry.Point(envelope.maxx, envelope.miny));
            ring.AddPoint(new gView.Framework.Geometry.Point(envelope.minx, envelope.miny));

            polygon.AddRing(ring);

            NofContours = polygon.RingCount;

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

            for (int i = 0; i < polygon.RingCount; i++)
            {
                Contour[i] = new GeomVertexList(polygon[i]);
            }
        }
コード例 #2
0
ファイル: geomWrapper.cs プロジェクト: jugstalt/gViewGisOS
        // path should contain only polylines ( use Flatten )
        // furthermore the constructor assumes that all Subpathes of path except the first one are holes
        public GeomPolygon(GraphicsPath path)
        {
            NofContours = 0;
            foreach (byte b in path.PathTypes)
            {
                if ((b & ((byte)PathPointType.CloseSubpath)) != 0)
                {
                    NofContours++;
                }
            }

            ContourIsHole = new bool[NofContours];
            Contour       = new GeomVertexList[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));
                    GeomVertexList vl         = new GeomVertexList(pointArray);
                    Contour[contourNr++] = vl;
                    contour.Clear();
                }
            }
        }
コード例 #3
0
ファイル: geomWrapper.cs プロジェクト: jugstalt/gViewGisOS
        /*
         * public GeomPolygon(IPolygon poly)
         * {
         *
         * }
         * */

        /*
         *      public static GeomPolygon FromFile( string filename, bool readHoleFlags )
         *      {
         *              return ClipWrapper.ReadPolygon( filename, readHoleFlags );
         *      }
         */
        public void AddContour(GeomVertexList contour, bool contourIsHole)
        {
            bool[]           hole = new bool[NofContours + 1];
            GeomVertexList[] cont = new GeomVertexList[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;
        }
コード例 #4
0
ファイル: geomWrapper.cs プロジェクト: jugstalt/gViewGisOS
        public GeomPolygon(IPolygon polygon, double generalizationDistance = 0)
        {
            if (polygon == null || polygon.RingCount == 0)
            {
                return;
            }
            NofContours = polygon.RingCount;

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

            for (int i = 0; i < polygon.RingCount; i++)
            {
                Contour[i] = new GeomVertexList(polygon[i]);
            }
        }