ArcObjects Library Reference  (GeoDatabase)    

ITopologyGraph__ReshapeEdgeGeometry

[Visual Basic 6.0]

'This example demonstrates how to use ReshapeEdgeGeometry

Sub ReshapeEdgeGeometryTopologyGraph()
Dim pMxDoc As IMxDocument
Dim pTopology As ITopology
Dim pTopologyLayer As ITopologyLayer
Dim pTopologyGraph As ITopologyGraph
Dim bsel As Boolean
Dim pTopologyEdge As ITopologyEdge
Dim pEnumTopologyEdge As IEnumTopologyEdge
Dim pAffine As IAffineTransformation2D
Dim pPol As IPolyline
Dim pGDset As IGeoDataset
Dim pApp As IApplication
Dim pDataset As IDataset
Dim pEditor As IEditor
Dim puid As New UID
Dim pConstructPoint As IConstructPoint
Dim pCarc As ICircularArc
Dim pSegColl As ISegmentCollection
Dim bReshaped As Boolean
Set pMxDoc = ThisDocument
'Assume that there is a topology layer in position 0 in TOC
If Not TypeOf pMxDoc.FocusMap.Layer(0) Is ITopologyLayer Then Exit Sub
Set pTopologyLayer = pMxDoc.FocusMap.Layer(0)
Set pTopology = pTopologyLayer.Topology
Set pDataset = pTopology.FeatureDataset
Set pGDset = pDataset
puid = "esriEditor.Editor"
Set pApp = Application
Set pEditor = pApp.FindExtensionByCLSID(puid)
pEditor.StartEditing pDataset.Workspace
pEditor.StartOperation
Set pTopologyGraph = pTopology.Cache
pTopologyGraph.Build pMxDoc.ActiveView.Extent, False
Set pEnumTopologyEdge = pTopologyGraph.Edges
Set pTopologyEdge = pEnumTopologyEdge.Next
Set pPol = pTopologyEdge.Geometry
Set pConstructPoint = New Point
pConstructPoint.ConstructAlong pPol, esriNoExtension, 0.5, True
Set pCarc = New CircularArc
'Create a circular arc based on the geometry of the edge
pCarc.PutCoords pConstructPoint, pPol.FromPoint, pPol.ToPoint, esriArcClockwise
Set pSegColl = New Path
pSegColl.AddSegment pCarc
bReshaped = pTopologyGraph.ReshapeEdgeGeometry(pTopologyEdge, pSegColl)
pTopologyGraph.Post pGDset.Extent 'Commit the topology edit in the database
pEditor.StopOperation "Stop operation"
pEditor.StopEditing True
End Sub


[C#]

        // This example demonstrates how to use ReshapeEdgeGeometry.
        public void esriGeoDatabase__ITopologyGraph__ReshapeEdgeGeometry(ITopology topology, IEnvelope extent)
        {
            IDataset dataset = (IDataset)topology;
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)dataset.Workspace;

            // Start an edit session on the workspace
            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            // Get a reference to the Topology Graph interface and build it
            ITopologyGraph topologyGraph = topology.Cache;
            topologyGraph.Build(extent, false);

            IEnumTopologyEdge enumtopologyEdge = topologyGraph.Edges;
            ITopologyEdge topologyEdge = enumtopologyEdge.Next();
            Boolean selected = topologyGraph.Select(esriTopologySelectionResultEnum.esriTopologySelectionResultNew, topologyEdge);

            // Get the geometry of the topology edge
            IPolyline polyline = (IPolyline)topologyEdge.Geometry;

            // Create a point along the line
            IConstructPoint constructPoint = new PointClass();
            constructPoint.ConstructAlong((ICurve)polyline, esriSegmentExtension.esriNoExtension, 0.5, true);

            // Create a circular arc based on the geometry of the edge
            ICircularArc circularArc = new CircularArcClass();
            circularArc.PutCoords((IPoint)constructPoint, (IPoint)polyline.FromPoint, (IPoint)polyline.ToPoint, esriArcOrientation.esriArcClockwise);

            object before = new object();
            object after = new object();
            ISegmentCollection segmentCollection = (ISegmentCollection)new Path();
            segmentCollection.AddSegment((ISegment)circularArc, ref before, ref after);
            Boolean reshaped = topologyGraph.ReshapeEdgeGeometry(topologyEdge, (IPath)segmentCollection);

            // Apply the transformation to the selected elements and post it to graph
            IEnvelope invalidArea;
            topologyGraph.Post(out invalidArea);

            // Stop the edit operation and session
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);
        }


[Visual Basic .NET, C++]
No example is available for Visual Basic .NET or C++. To view a Visual Basic 6.0 or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.