/*
         * private void OLDcomputeLineBufferCurve(Coordinate[] inputPts)
         * {
         * int n = inputPts.length - 1;
         *
         * // compute points for left side of line
         * initSideSegments(inputPts[0], inputPts[1], Position.LEFT);
         * for (int i = 2; i <= n; i++) {
         * addNextSegment(inputPts[i], true);
         * }
         * addLastSegment();
         * // add line cap for end of line
         * addLineEndCap(inputPts[n - 1], inputPts[n]);
         *
         * // compute points for right side of line
         * initSideSegments(inputPts[n], inputPts[n - 1], Position.LEFT);
         * for (int i = n - 2; i >= 0; i--) {
         * addNextSegment(inputPts[i], true);
         * }
         * addLastSegment();
         * // add line cap for start of line
         * addLineEndCap(inputPts[1], inputPts[0]);
         *
         * vertexList.closeRing();
         * }
         */

        private void ComputeSingleSidedBufferCurve(Coordinate[] inputPts, bool isRightSide,
                                                   OffsetSegmentGenerator segGen)
        {
            var distTol = SimplifyTolerance(_distance);

            if (isRightSide)
            {
                // add original line
                segGen.AddSegments(inputPts, true);

                //---------- compute points for right side of line
                // Simplify the appropriate side of the line before generating
                var simp2 = BufferInputLineSimplifier.Simplify(inputPts, -distTol);
                // MD - used for testing only (to eliminate simplification)
                // Coordinate[] simp2 = inputPts;
                var n2 = simp2.Length - 1;

                // since we are traversing line in opposite order, offset position is still LEFT
                segGen.InitSideSegments(simp2[n2], simp2[n2 - 1], Positions.Left);
                segGen.AddFirstSegment();
                for (var i = n2 - 2; i >= 0; i--)
                {
                    segGen.AddNextSegment(simp2[i], true);
                }
            }
            else
            {
                // add original line
                segGen.AddSegments(inputPts, false);

                //--------- compute points for left side of line
                // Simplify the appropriate side of the line before generating
                var simp1 = BufferInputLineSimplifier.Simplify(inputPts, distTol);
                // MD - used for testing only (to eliminate simplification)
                //      Coordinate[] simp1 = inputPts;

                var n1 = simp1.Length - 1;
                segGen.InitSideSegments(simp1[0], simp1[1], Positions.Left);
                segGen.AddFirstSegment();
                for (var i = 2; i <= n1; i++)
                {
                    segGen.AddNextSegment(simp1[i], true);
                }
            }
            segGen.AddLastSegment();
            segGen.CloseRing();
        }
예제 #2
0
        private void ComputeLineBufferCurve(Coordinate[] inputPts, OffsetSegmentGenerator segGen)
        {
            double distTol = SimplifyTolerance(_distance);

            //--------- compute points for left side of line
            // Simplify the appropriate side of the line before generating
            var simp1 = BufferInputLineSimplifier.Simplify(inputPts, distTol);
            // MD - used for testing only (to eliminate simplification)
            //    Coordinate[] simp1 = inputPts;

            int n1 = simp1.Length - 1;

            segGen.InitSideSegments(simp1[0], simp1[1], Positions.Left);
            for (int i = 2; i <= n1; i++)
            {
                segGen.AddNextSegment(simp1[i], true);
            }
            segGen.AddLastSegment();
            // add line cap for end of line
            segGen.AddLineEndCap(simp1[n1 - 1], simp1[n1]);

            //---------- compute points for right side of line
            // Simplify the appropriate side of the line before generating
            var simp2 = BufferInputLineSimplifier.Simplify(inputPts, -distTol);
            // MD - used for testing only (to eliminate simplification)
            //    Coordinate[] simp2 = inputPts;
            int n2 = simp2.Length - 1;

            // since we are traversing line in opposite order, offset position is still LEFT
            segGen.InitSideSegments(simp2[n2], simp2[n2 - 1], Positions.Left);
            for (int i = n2 - 2; i >= 0; i--)
            {
                segGen.AddNextSegment(simp2[i], true);
            }
            segGen.AddLastSegment();
            // add line cap for start of line
            segGen.AddLineEndCap(simp2[1], simp2[0]);

            segGen.CloseRing();
        }
예제 #3
0
        private void ComputeRingBufferCurve(Coordinate[] inputPts, Positions side)
        {
            // simplify input line to improve performance
            double distTol = SimplifyTolerance(_distance);

            // ensure that correct side is simplified
            if (side == Positions.Right)
            {
                distTol = -distTol;
            }
            var simp = BufferInputLineSimplifier.Simplify(inputPts, distTol);
            // Coordinate[] simp = inputPts;

            int n = simp.Length - 1;

            InitSideSegments(simp[n - 1], simp[0], side);
            for (int i = 1; i <= n; i++)
            {
                bool addStartPoint = i != 1;
                AddNextSegment(simp[i], addStartPoint);
            }
            _vertexList.CloseRing();
        }
        private void ComputeRingBufferCurve(Coordinate[] inputPts, Positions side, OffsetSegmentGenerator segGen)
        {
            // simplify input line to improve performance
            var distTol = SimplifyTolerance(_distance);

            // ensure that correct side is simplified
            if (side == Positions.Right)
            {
                distTol = -distTol;
            }
            var simp = BufferInputLineSimplifier.Simplify(inputPts, distTol);
            // MD - used for testing only (to eliminate simplification)
            // Coordinate[] simp = inputPts;

            var n = simp.Length - 1;

            segGen.InitSideSegments(simp[n - 1], simp[0], side);
            for (var i = 1; i <= n; i++)
            {
                var addStartPoint = i != 1;
                segGen.AddNextSegment(simp[i], addStartPoint);
            }
            segGen.CloseRing();
        }
        /// <summary>
        /// Simplify the input coordinate list.
        /// If the distance tolerance is positive,
        /// concavities on the LEFT side of the line are simplified.
        /// If the supplied distance tolerance is negative,
        /// concavities on the RIGHT side of the line are simplified.
        /// </summary>
        /// <param name="inputLine">The coordinate list to simplify</param>
        /// <param name="distanceTol">simplification distance tolerance to use</param>
        /// <returns>The simplified coordinate list</returns>
        public static Coordinate[] Simplify(Coordinate[] inputLine, double distanceTol)
        {
            var simp = new BufferInputLineSimplifier(inputLine);

            return(simp.Simplify(distanceTol));
        }
 /// <summary>
 /// Simplify the input coordinate list.
 /// If the distance tolerance is positive,
 /// concavities on the LEFT side of the line are simplified.
 /// If the supplied distance tolerance is negative,
 /// concavities on the RIGHT side of the line are simplified.
 /// </summary>
 /// <param name="inputLine">The coordinate list to simplify</param>
 /// <param name="distanceTol">simplification distance tolerance to use</param>
 /// <returns>The simplified coordinate list</returns>
 public static Coordinate[] Simplify(Coordinate[] inputLine, double distanceTol)
 {
     var simp = new BufferInputLineSimplifier(inputLine);
     return simp.Simplify(distanceTol);
 }