IGeometryCollection rings = (IGeometryCollection) editGeometry; // the rings of the edit-geometry
IGeometryCollection paths = (IGeometryCollection) reshaper; // the paths of the reshaper
if (paths.GeometryCount > 1) throw new ArgumentException("The reshape-geometry must be single-part");
for (int i = 0; i < rings.GeometryCount; i++) {
// get the affected rings of the current polygon
IRelationalOperator relOp1 = (IRelationalOperator) reshaper.FromPoint;
IRelationalOperator relOp2 = (IRelationalOperator) reshaper.ToPoint;
// check if Ring touches from- and toPoint of the reshaper
if (relOp1.Touches(singlePolygon) && relOp2.Touches(singlePolygon)) {
IPath path = (IPath) paths.get_Geometry(0);
bool res = ring.Reshape(path);
// only in case of success the ring is reshaped
if (res && !ring.IsEmpty) return editGeometry;
}
}
Are the shaper geometry and edit geometry simple?
Sub Test_Reshape()
Dim mxDoc As IMxDocument
Set mxDoc = ThisDocument
Dim featLyr As IFeatureLayer
Dim featCls As IFeatureClass
Set featLyr = mxDoc.FocusMap.Layer(0) 'PolylineFC
Set featCls = featLyr.FeatureClass
Dim feat0 As IFeature
Set feat0 = featCls.GetFeature(0)
Dim geomColl0 As IGeometryCollection
Set geomColl0 = feat0.ShapeCopy
Dim geom0 As IGeometry
Set geom0 = geomColl0.Geometry(0)
Debug.Print geom0.GeometryType
Set featLyr = mxDoc.FocusMap.Layer(1) 'SlaveClass
Set featCls = featLyr.FeatureClass
Dim feat1 As IFeature
Set feat1 = featCls.GetFeature(0)
Dim geomColl1 As IGeometryCollection
Set geomColl1 = feat1.ShapeCopy
Dim geom1 As IGeometry
Set geom1 = geomColl1.Geometry(0)
Debug.Print geom1.GeometryType
Dim ring As IRing
Set ring = geom1
Dim path As IPath
Set path = geom0
Debug.Print ring.Reshape(path)
Debug.Print ring.IsEmpty
End Sub