private void ComputeLineBufferCurve(Coordinate[] inputPts, OffsetSegmentGenerator segGen) { var 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; var 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; 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); for (var 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(); }
/* * 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(); }
/* 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(); }