代码
private static void CircularArcToDensifiedLines(IFeatureWorkspace pWorkspace, string sPolygonFeatureClassName, int nSegLength = 10)
{
try
{
var pFeatureClass = pWorkspace.OpenFeatureClass(sPolygonFeatureClassName);
var pFeatureCursor = pFeatureClass.Search(null, false);
var bChange = false;
IFeature pFeature;
while (null != (pFeature = pFeatureCursor.NextFeature()))
{
var pGeoCol = pFeature.ShapeCopy as IGeometryCollection;
for (int i = pGeoCol.GeometryCount - 1; i >= 0; i--)
{
var pGeo = pGeoCol.Geometry[i];
if (pGeo.GeometryType == esriGeometryType.esriGeometryRing)
{
var pSegCol = pGeo as ISegmentCollection;
var nCount = pSegCol.SegmentCount;
for (int j = nCount - 1; j >= 0; j--)
{
var pSeg = pSegCol.Segment[j];
if (pSeg.GeometryType != esriGeometryType.esriGeometryCircularArc)
{
continue;
}
var pCircularArc = pSeg as ICircularArc;
var nLength = pCircularArc.Length;
var nShareCount = (int)(nLength / nSegLength) + 1;
if (nShareCount < 3)
{
nShareCount = 3;
}
int nNum = 0;
var lstLine = new ILine[nShareCount];
IGeometryBridge2 geometryBridge2 = new GeometryEnvironmentClass();
geometryBridge2.Densify(pSeg, 0.1, ref nNum, ref lstLine);
var pGeometryBag = new GeometryBagClass();
ISegmentCollection pGeometryCollection = new PolygonClass();
lstLine.ToList().ForEach(p => pGeometryCollection.AddSegment(p as ISegment));
bChange = true;
if (bChange)
{
pSegCol.RemoveSegments(j, 1, false);
pSegCol.InsertSegmentCollection(j, pGeometryCollection);
}
}
}
}
if (bChange)
{
pFeature.Shape = pGeoCol as IGeometry;
pFeature.Store();
}
}
}
catch { }
}