[Visual Basic 6.0]'This example demonstrates how to use the IRing::GetSubCurveEx method
Sub GetSubCurveEx_Example()
Dim pRing As IRing, pOutCurve As ICurve
Dim dDist As Double, dTotalDist As Double
Dim pClone As IClone, bAsRatio As Boolean
Dim bCCW As Boolean, bUseRingOriention As Boolean
Dim dFromDist As Double, dToDistance As Double
Set pClone = CreateRing
Debug.Print "********************************************************"
Debug.Print "bAsRatio = true, bCCW = true, bUseRingOriention= true"
Debug.Print "********************************************************"
Set pRing = pClone.Clone
dTotalDist = pRing.Length
bAsRatio = True
bCCW = True
bUseRingOriention = True
For dDist = 0 To dTotalDist Step dTotalDist / 10
dFromDist = dDist / dTotalDist
dToDistance = (dDist + dTotalDist / 10) / dTotalDist
Set pOutCurve = pRing.GetSubcurveEx(dFromDist, dToDistance, bAsRatio, bCCW, bUseRingOriention)
Debug.Print "From distance : " & dFromDist
Debug.Print "To distance : " & dToDistance
Debug.Print "From X, Y : " & pOutCurve.FromPoint.X & " , " & pOutCurve.FromPoint.Y
Debug.Print "To X, Y : " & pOutCurve.ToPoint.X & " , " & pOutCurve.ToPoint.Y
Debug.Print "Curve Length : " & pOutCurve.Length
NextDebug.Print "********************************************************"
Debug.Print "bAsRatio = false, bCCW = true, bUseRingOriention= true"
Debug.Print "********************************************************"
Set pRing = pClone.Clone
dTotalDist = pRing.Length
bAsRatio = False
bCCW = True
bUseRingOriention = True
For dDist = 0 To dTotalDist Step dTotalDist / 10
dFromDist = dDist
dToDistance = dDist + dTotalDist / 10
Set pOutCurve = pRing.GetSubcurveEx(dFromDist, dToDistance, bAsRatio, bCCW, bUseRingOriention)
Debug.Print "From distance : " & dFromDist
Debug.Print "To distance : " & dToDistance
Debug.Print "From X, Y : " & pOutCurve.FromPoint.X & " , " & pOutCurve.FromPoint.Y
Debug.Print "To X, Y : " & pOutCurve.ToPoint.X & " , " & pOutCurve.ToPoint.Y
Debug.Print "Curve Length : " & pOutCurve.Length
NextDebug.Print "********************************************************"
Debug.Print "bAsRatio = true, bCCW = false, bUseRingOriention= true"
Debug.Print "********************************************************"
Set pRing = pClone.Clone
dTotalDist = pRing.Length
bAsRatio = True
bCCW = False
bUseRingOriention = True
For dDist = 0 To dTotalDist Step dTotalDist / 10
dFromDist = dDist / dTotalDist
dToDistance = (dDist + dTotalDist / 10) / dTotalDist
Set pOutCurve = pRing.GetSubcurveEx(dFromDist, dToDistance, bAsRatio, bCCW, bUseRingOriention)
Debug.Print "From distance : " & dFromDist
Debug.Print "To distance : " & dToDistance
Debug.Print "From X, Y : " & pOutCurve.FromPoint.X & " , " & pOutCurve.FromPoint.Y
Debug.Print "To X, Y : " & pOutCurve.ToPoint.X & " , " & pOutCurve.ToPoint.Y
Debug.Print "Curve Length : " & pOutCurve.Length
NextDebug.Print "********************************************************"
Debug.Print "bAsRatio = true, bCCW = true, bUseRingOriention= false"
Debug.Print "********************************************************"
Set pRing = pClone.Clone
dTotalDist = pRing.Length
bAsRatio = True
bCCW = True
bUseRingOriention = False
For dDist = 0 To dTotalDist Step dTotalDist / 10
dFromDist = dDist / dTotalDist
dToDistance = (dDist + dTotalDist / 10) / dTotalDist
Set pOutCurve = pRing.GetSubcurveEx(dFromDist, dToDistance, bAsRatio, bCCW, bUseRingOriention)
Debug.Print "From distance : " & dFromDist
Debug.Print "To distance : " & dToDistance
Debug.Print "From X, Y : " & pOutCurve.FromPoint.X & " , " & pOutCurve.FromPoint.Y
Debug.Print "To X, Y : " & pOutCurve.ToPoint.X & " , " & pOutCurve.ToPoint.Y
Debug.Print "Curve Length : " & pOutCurve.Length
NextDebug.Print "********************************************************"
Debug.Print "bAsRatio = false, bCCW = false, bUseRingOriention= true"
Debug.Print "********************************************************"
Set pRing = pClone.Clone
dTotalDist = pRing.Length
bAsRatio = False
bCCW = False
bUseRingOriention = True
For dDist = 0 To dTotalDist Step dTotalDist / 10
dFromDist = dDist
dToDistance = (dDist + dTotalDist / 10)
Set pOutCurve = pRing.GetSubcurveEx(dFromDist, dToDistance, bAsRatio, bCCW, bUseRingOriention)
Debug.Print "From distance : " & dFromDist
Debug.Print "To distance : " & dToDistance
Debug.Print "From X, Y : " & pOutCurve.FromPoint.X & " , " & pOutCurve.FromPoint.Y
Debug.Print "To X, Y : " & pOutCurve.ToPoint.X & " , " & pOutCurve.ToPoint.Y
Debug.Print "Curve Length : " & pOutCurve.Length
NextDebug.Print "********************************************************"
Debug.Print "bAsRatio = true, bCCW = false, bUseRingOriention= false"
Debug.Print "********************************************************"
Set pRing = pClone.Clone
dTotalDist = pRing.Length
bAsRatio = True
bCCW = False
bUseRingOriention = False
For dDist = 0 To dTotalDist Step dTotalDist / 10
dFromDist = dDist / dTotalDist
dToDistance = (dDist + dTotalDist / 10) / dTotalDist
Set pOutCurve = pRing.GetSubcurveEx(dFromDist, dToDistance, bAsRatio, bCCW, bUseRingOriention)
Debug.Print "From distance : " & dFromDist
Debug.Print "To distance : " & dToDistance
Debug.Print "From X, Y : " & pOutCurve.FromPoint.X & " , " & pOutCurve.FromPoint.Y
Debug.Print "To X, Y : " & pOutCurve.ToPoint.X & " , " & pOutCurve.ToPoint.Y
Debug.Print "Curve Length : " & pOutCurve.Length
NextDebug.Print "********************************************************"
Debug.Print "bAsRatio = false, bCCW = true, bUseRingOriention= false"
Debug.Print "********************************************************"
Set pRing = pClone.Clone
dTotalDist = pRing.Length
bAsRatio = False
bCCW = True
bUseRingOriention = False
For dDist = 0 To dTotalDist Step dTotalDist / 10
dFromDist = dDist
dToDistance = (dDist + dTotalDist / 10)
Set pOutCurve = pRing.GetSubcurveEx(dFromDist, dToDistance, bAsRatio, bCCW, bUseRingOriention)
Debug.Print "From distance : " & dFromDist
Debug.Print "To distance : " & dToDistance
Debug.Print "From X, Y : " & pOutCurve.FromPoint.X & " , " & pOutCurve.FromPoint.Y
Debug.Print "To X, Y : " & pOutCurve.ToPoint.X & " , " & pOutCurve.ToPoint.Y
Debug.Print "Curve Length : " & pOutCurve.Length
NextEnd Sub
Private Function CreateRing() As IRing
Dim pSegColl As ISegmentCollection, pLine As ILine
Dim pPoints(3) As IPoint, i As Long, dPi As Double
Dim pCArc As ICircularArc, pCenterCArc As IPoint
Dim pEArc As IEllipticArc, pCenterEArc As IPoint
Dim pBezier As IBezierCurve, pBezControlPoints(3) As IPoint
'PI value
dPi = Atn(1) * 4
Set pSegColl = New Ring
'Create the end points for all the segments
For i = 0 To 3
Set pPoints(i) = New Point
Next
pPoints(0).PutCoords 10, 10
pPoints(1).PutCoords 10, 30
pPoints(2).PutCoords 30, 30
pPoints(3).PutCoords 30, 5
'Create 4 segments
'1 Line, 1 CircularArc, 1 EllipticArc, 1 Bezier Curve
Set pLine = New esriGeometry.Line
pLine.PutCoords pPoints(0), pPoints(1)
Set pCArc = New CircularArc
Set pCenterCArc = New Point
pCenterCArc.PutCoords 20, 30
pCArc.PutCoords pCenterCArc, pPoints(1), pPoints(2), esriArcClockwise
Set pEArc = New EllipticArc
Set pCenterEArc = New Point
pCenterEArc.PutCoords 30, 17.5
pEArc.PutCoordsByAngle False, pCenterEArc, dPi / 2, dPi, -dPi / 2, 12.5, 0.2
Set pBezier = New BezierCurve
Set pBezControlPoints(0) = pPoints(3)
Set pBezControlPoints(1) = New Point
pBezControlPoints(1).PutCoords 25, 0
Set pBezControlPoints(2) = New Point
pBezControlPoints(2).PutCoords 15, 10
Set pBezControlPoints(3) = pPoints(0)
pBezier.PutCoords 4, pBezControlPoints(0)
'Add the segments to the polygon
pSegColl.AddSegment pLine
pSegColl.AddSegment pCArc
pSegColl.AddSegment pEArc
pSegColl.AddSegment pBezier
Set CreateRing = pSegCollEnd Function
[C#]public void Driver() { IRing ring = CreateRing(); PrintSubcurveProperties(ring, true, true, true); PrintSubcurveProperties(ring, false, true, true); PrintSubcurveProperties(ring, true, false, true); PrintSubcurveProperties(ring, true, true, false); PrintSubcurveProperties(ring, false, false, true); PrintSubcurveProperties(ring, true, false, false); PrintSubcurveProperties(ring, false, true, false); } private void PrintSubcurveProperties(IRing ring, bool asRatio, bool isCCW, bool useRingOrientation) { String report = "asRatio = " + asRatio + ", isCCW = " + isCCW + ", useRingOrientation= " + useRingOrientation + "\n"; double totalDistance = ring.Length; for (int distance = 0; distance < totalDistance; distance = (int) (distance + (totalDistance / 10))) { double fromDistance = distance / totalDistance; double toDistance = (distance + (totalDistance / 10)) / totalDistance; ICurve outCurve = ring.GetSubcurveEx(fromDistance, toDistance, asRatio, isCCW, useRingOrientation); report = report + "From distance : " + fromDistance + "\n"; report = report + "To distance : " + toDistance + "\n"; report = report + "From X, Y : " + outCurve.FromPoint.X + " , " + outCurve.FromPoint.Y + "\n"; report = report + "To X, Y : " + outCurve.ToPoint.X + " , " + outCurve.ToPoint.Y + "\n"; report = report + "Curve Length : " + outCurve.Length + "\n\n"; } System.Windows.Forms.MessageBox.Show(report); } private IRing CreateRing() { //Create the end points for all the segments IPoint[] points = new IPoint[4]; for(int i = 0; i < 4; i++) { points[i] = new PointClass(); } points[0].PutCoords(10, 10); points[1].PutCoords(10, 30); points[2].PutCoords(30, 30); points[3].PutCoords(30, 5); //Create 4 segments //1 Line, 1 CircularArc, 1 EllipticArc, 1 Bezier Curve ILine line = new LineClass(); line.PutCoords(points[0], points[1]); IPoint centerPointCircularArc = new PointClass(); centerPointCircularArc.PutCoords(20, 30); ICircularArc circularArc = new CircularArcClass(); circularArc.PutCoords(centerPointCircularArc, points[1], points[2], esriArcOrientation.esriArcClockwise); IPoint centerPointEllipticArc = new PointClass(); centerPointEllipticArc.PutCoords(30, 17.5); IEllipticArc ellipticArc = new EllipticArcClass(); ellipticArc.PutCoordsByAngle(false, centerPointEllipticArc, Math.PI / 2, Math.PI, -Math.PI / 2, 12.5, 0.2); IBezierCurveGEN bezier = new BezierCurveClass(); IPoint[] bezierControlPoints = new IPoint[4]; bezierControlPoints[0] = points[3]; bezierControlPoints[1] = new PointClass(); bezierControlPoints[1].PutCoords(25, 0); bezierControlPoints[2] = new PointClass(); bezierControlPoints[2].PutCoords(15, 10); bezierControlPoints[3] = points[0]; bezier.PutCoords(ref bezierControlPoints); //Add the segments to the polygon object Missing = Type.Missing; ISegmentCollection segmentCollection = new RingClass(); segmentCollection.AddSegment(line as ISegment, ref Missing, ref Missing); segmentCollection.AddSegment(circularArc as ISegment, ref Missing, ref Missing); segmentCollection.AddSegment(ellipticArc as ISegment, ref Missing, ref Missing); segmentCollection.AddSegment(bezier as ISegment, ref Missing, ref Missing); return segmentCollection as IRing; }
[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
in the upper-left corner of the page.