public IGeometryBag ConstructPolygonByLine(IGeometryBag igeometryBag_0) { int i; IPolygon polygon; IGeometryCollection geometryBagClass = new GeometryBag() as IGeometryCollection; object value = Missing.Value; IArray array = this.SplitLine(igeometryBag_0); int[] numArray = new int[array.Count]; IArray arrayClass = new Array(); for (i = 0; i < array.Count; i++) { numArray[i] = 0; } IGeometry element = null; IGeometry geometry = null; for (i = 0; i < array.Count; i++) { element = array.Element[i] as IGeometry; IPolyline polyline = (IPolyline)element; geometry = element; if (this.method_3(array, polyline.FromPoint) != 1 && this.method_3(array, polyline.ToPoint) != 1) { if (!polyline.IsClosed) { if ((numArray[i] & 2) == 0) { numArray[i] = numArray[i] | 2; polygon = this.BulidPoly(array, numArray, geometry, false); if (polygon != null) { geometryBagClass.AddGeometry(polygon, ref value, ref value); } } if ((numArray[i] & 1) == 0) { numArray[i] = numArray[i] | 1; polygon = this.BulidPoly(array, numArray, geometry, true); if (polygon != null) { geometryBagClass.AddGeometry(polygon, ref value, ref value); } } } else { ISegmentCollection polygonClass = new Polygon() as ISegmentCollection; polygonClass.AddSegmentCollection((ISegmentCollection)polyline); polygon = (IPolygon)polygonClass; ((ITopologicalOperator)polygon).Simplify(); geometryBagClass.AddGeometry(polygon, ref value, ref value); } } } return((IGeometryBag)geometryBagClass); }
public IPolygon BulidPoly(IArray iarray_0, int[] int_0, IGeometry igeometry_0, bool bool_1) { IPolygon polygon; bool flag; ISegmentCollection polygonClass = new Polygon() as ISegmentCollection; polygonClass.AddSegmentCollection((ISegmentCollection)(igeometry_0 as IClone).Clone()); this.method_1(iarray_0, igeometry_0); bool flag1 = true; IGeometry igeometry0 = igeometry_0; while (true) { igeometry0 = (!flag1 ? this.method_4(iarray_0, igeometry0, ((IPolyline)igeometry0).FromPoint, bool_1, ref flag1) : this.method_4(iarray_0, igeometry0, ((IPolyline)igeometry0).ToPoint, bool_1, ref flag1)); if (igeometry0 == null) { polygon = null; break; } else if (igeometry_0 == igeometry0) { ((IPolygon)polygonClass).Close(); double area = ((IArea)polygonClass).Area; if (area <= 0 || bool_1) { flag = (area >= 0 ? true : !bool_1); } else { flag = false; } if (flag) { polygon = null; break; } else { ((ITopologicalOperator)polygonClass).Simplify(); ((IPolygon)polygonClass).Close(); polygon = (IPolygon)polygonClass; break; } } else { ICurve curve = (ICurve)((IClone)igeometry0).Clone(); int num = this.method_1(iarray_0, igeometry0); if (!flag1) { if (!bool_1) { int_0[num] = int_0[num] | 1; } else { int_0[num] = int_0[num] | 2; } curve.ReverseOrientation(); } else if (!bool_1) { int_0[num] = int_0[num] | 2; } else { int_0[num] = int_0[num] | 1; } polygonClass.AddSegmentCollection((ISegmentCollection)curve); } } return(polygon); }