IPolygon 遍历 外环 内环

 //Set the polygon
      IPolygon4 polygon = currentFeature.Shape as IPolygon4;
      //IPolygon4.ExteriorRingBag should be used instead of IPolygon.QueryExteriorRings,
      //which does not work in .NET because of C-Style Arrays
      IGeometryBag exteriorRings = polygon.ExteriorRingBag;
    
      //For each exterior rings find the number of interior rings associated with it and print it
      IEnumGeometry exteriorRingsEnum = exteriorRings as IEnumGeometry;
      exteriorRingsEnum.Reset();
      IRing currentExteriorRing = exteriorRingsEnum.Next() as IRing;
      int counter = 1;
      System.Windows.Forms.MessageBox.Show("ExteriorRingCount = " + polygon.ExteriorRingCount);
      while(currentExteriorRing != null)
      {
        //IPolygon4.get_InteriorRingBag should be used instead of IPolygon.QueryInteriorRings,
        //which does not work in .NET because of C-Style Arrays
        IGeometryBag interiorRings = polygon.get_InteriorRingBag(currentExteriorRing);
        //Note we do nothing with the interiorRings, but you can use them the same way as the IGeometryBag exteriorRings
        System.Windows.Forms.MessageBox.Show("Exterior ring number " + counter + " InteriorRingCount = " + polygon.get_InteriorRingCount(currentExteriorRing));
        currentExteriorRing = exteriorRingsEnum.Next() as IRing;
        counter++;
      }


 

posted @ 2012-04-06 23:35  zhh  阅读(1381)  评论(0编辑  收藏  举报