当前位置: 首页>>代码示例>>C#>>正文


C# IPolyline.GetSubcurve方法代码示例

本文整理汇总了C#中IPolyline.GetSubcurve方法的典型用法代码示例。如果您正苦于以下问题:C# IPolyline.GetSubcurve方法的具体用法?C# IPolyline.GetSubcurve怎么用?C# IPolyline.GetSubcurve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPolyline的用法示例。


在下文中一共展示了IPolyline.GetSubcurve方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ClipContour

        /// <summary>
        /// clip a polyline at the specified lengths
        /// </summary>
        public static IPolyline ClipContour(IPoint npsPoint, IPolyline npsPolyline, double RangeLeft, double RangeRight)
        {
            ICurve NewPolyline = null, pl2, pl1;
            IPoint npsExactPoint;
            double PolylineLength, DistanceFromStart = 0, DistanceFromCurve = 0, NewLineEnd,
                AmountOver, start1 = 0, start2 = 0, end1 = 0, end2 = 0, NewLineStart;
            bool npsRightSide = false, IsOutOfBoundsLeft, IsOutOfBoundsRight;
            ISegmentCollection newpl = null;

            if (npsPolyline == null) return null;

            PolylineLength = npsPolyline.Length;

            //get the distance of the point from the start of the contour
            npsExactPoint = new PointClass();
            npsPolyline.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, npsPoint, false,
                npsExactPoint, ref DistanceFromStart, ref DistanceFromCurve, ref npsRightSide);

            //if (contour)polyline is not a closed line
            if (npsPolyline.IsClosed == false)
            {

                IsOutOfBoundsLeft = false;
                IsOutOfBoundsRight = false;

                NewLineStart = DistanceFromStart - RangeLeft;
                NewLineEnd = DistanceFromStart + RangeRight;

                if (NewLineStart < 0) IsOutOfBoundsLeft = true;

                if (NewLineEnd > PolylineLength) IsOutOfBoundsRight = true;

                //if contour is outbound to the left, then try to shift it to the right
                if (IsOutOfBoundsLeft == true && IsOutOfBoundsRight == false)
                {

                    AmountOver = (DistanceFromStart - RangeLeft) * -1;

                    if (((DistanceFromStart + RangeRight) + AmountOver) < PolylineLength)
                    {
                        NewLineStart = 0;
                        NewLineEnd = (DistanceFromStart + RangeRight) + AmountOver;
                    }
                    else
                    {
                        NewLineStart = -1;
                        NewLineEnd = -1;
                    }
                }

                //if contour is out of bounds to the right, then try to shift it to the left
                if (IsOutOfBoundsLeft == false && IsOutOfBoundsRight == true)
                {
                    AmountOver = (DistanceFromStart + RangeRight) - PolylineLength;

                    if (((DistanceFromStart - RangeLeft) - AmountOver) >= 0)
                    {

                        NewLineStart = (DistanceFromStart - RangeLeft) - AmountOver;
                        NewLineEnd = PolylineLength;
                    }
                    else
                    {
                        NewLineStart = -1;
                        NewLineEnd = -1;
                    }
                }

                //since the contour is to short on both ends to create the new polyline,abound operation
                if (IsOutOfBoundsLeft == true && IsOutOfBoundsRight == true)
                {
                    NewLineStart = -1;
                    NewLineEnd = -1;
                }

                if (NewLineStart != -1 && NewLineEnd != -1)
                {

                    NewPolyline = new PolylineClass();
                    npsPolyline.GetSubcurve(NewLineStart, NewLineEnd, false, out NewPolyline);

                }
            }
            else //if polyline is closed
            {
                if ((RangeLeft + RangeRight) < PolylineLength)
                {

                    pl1 = new PolylineClass();
                    pl2 = new PolylineClass();
                    newpl = new PolylineClass();

                    //if desired subcurve does not cross the start/end point of the closed polyline(circular) then get
                    //a sub curve as normal
                    if ((DistanceFromStart - RangeLeft) >= 0 && (DistanceFromStart + RangeRight) < PolylineLength)
                    {

//.........这里部分代码省略.........
开发者ID:regan-sarwas,项目名称:NPSTransectTool,代码行数:101,代码来源:Utility.cs


注:本文中的IPolyline.GetSubcurve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。