/*private*/
void
OffsetCurveBuilder::computeLineBufferCurve(const CoordinateSequence& inputPts)
{
	double distTol = simplifyTolerance(distance);

	//--------- compute points for left side of line
#ifndef SKIP_INPUT_SIMPLIFICATION
	// Simplify the appropriate side of the line before generating
	std::auto_ptr<CoordinateSequence> simp1_ = 
		BufferInputLineSimplifier::simplify(inputPts, distTol);
	const CoordinateSequence& simp1 = *simp1_;
#else
	// MD - used for testing only (to eliminate simplification)
	const CoordinateSequence& simp1 = inputPts;
#endif


	int n1 = simp1.size() - 1;
	initSideSegments(simp1[0], simp1[1], Position::LEFT);
	for (int i = 2; i <= n1; ++i) {
		addNextSegment(simp1[i], true);
	}
	addLastSegment();
	// add line cap for end of line
	addLineEndCap(simp1[n1-1], simp1[n1]);

	// Record the index of the end of line cap.
	endCapIndex = vertexList->size() - 2 ;


	//---------- compute points for right side of line
#ifndef SKIP_INPUT_SIMPLIFICATION
	// Simplify the appropriate side of the line before generating
	std::auto_ptr<CoordinateSequence> simp2_ = 
		BufferInputLineSimplifier::simplify(inputPts, -distTol);
	const CoordinateSequence& simp2 = *simp2_;
#else
	// MD - used for testing only (to eliminate simplification)
	const CoordinateSequence& simp2 = inputPts;
#endif

	int n2 = simp2.size() - 1;
	initSideSegments(simp2[n2], simp2[n2-1], Position::LEFT);
	for (int i = n2-2; i >= 0; --i) {
		addNextSegment(simp2[i], true);
	}
	addLastSegment();
	// add line cap for start of line
	addLineEndCap(simp2[1], simp2[0]);

	vertexList->closeRing();
}
예제 #2
0
/*private*/
void
OffsetCurveBuilder::computeLineBufferCurve(const CoordinateSequence& inputPts)
{
	int n=inputPts.size()-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();
}