Example #1
0
        private void ComputePointCurve(Coordinate pt, OffsetSegmentGenerator segGen)
        {
            switch (_bufParams.EndCapStyle)
            {
            case EndCapStyle.Round:
                segGen.CreateCircle(pt);
                break;

            case EndCapStyle.Square:
                segGen.CreateSquare(pt);
                break;
                // otherwise curve is empty (e.g. for a butt cap);
            }
        }
Example #2
0
        /*
         * 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)
        {
            double 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;
                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);
                segGen.AddFirstSegment();
                for (int 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;

                int n1 = simp1.Length - 1;
                segGen.InitSideSegments(simp1[0], simp1[1], Positions.Left);
                segGen.AddFirstSegment();
                for (int i = 2; i <= n1; i++)
                {
                    segGen.AddNextSegment(simp1[i], true);
                }
            }
            segGen.AddLastSegment();
            segGen.CloseRing();
        }
Example #3
0
        private void ComputeRingBufferCurve(Coordinate[] inputPts, Positions side, OffsetSegmentGenerator segGen)
        {
            // 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);
            // MD - used for testing only (to eliminate simplification)
            // Coordinate[] simp = inputPts;

            int n = simp.Length - 1;

            segGen.InitSideSegments(simp[n - 1], simp[0], side);
            for (int i = 1; i <= n; i++)
            {
                bool addStartPoint = i != 1;
                segGen.AddNextSegment(simp[i], addStartPoint);
            }
            segGen.CloseRing();
        }