# [Piglit] [PATCH 19/19] glean: Remove SpiralStrip2D and SpiralTri2D.

Kenneth Graunke kenneth at whitecape.org
Mon Dec 31 18:41:08 PST 2012

```Both of these were unused.
---
tests/glean/geomutil.cpp | 156 -----------------------------------------------
tests/glean/geomutil.h   |  20 ------
2 files changed, 176 deletions(-)

diff --git a/tests/glean/geomutil.cpp b/tests/glean/geomutil.cpp
index 01645f7..1852332 100644
--- a/tests/glean/geomutil.cpp
+++ b/tests/glean/geomutil.cpp
@@ -80,162 +80,6 @@ RandomMesh2D::~RandomMesh2D() {
} // RandomMesh2D::~RandomMesh2D

-
-///////////////////////////////////////////////////////////////////////////////
-// SpiralStrip2D: Generate (x,y) vertices for a triangle strip of arbitrary
-//	length.  The triangles are of approximately equal size, and arranged
-//	in a spiral so that a reasonably large number of triangles can be
-//	packed into a small screen area.
-///////////////////////////////////////////////////////////////////////////////
-SpiralStrip2D::SpiralStrip2D(int nPoints, float minX, float maxX,
-    float minY, float maxY) {
-
-	// Most of the complexity of this code results from attempting
-	// to keep the triangles approximately equal in area.
-	//
-	// Conceptually, we construct concentric rings whose inner and
-	// outer radii differ by a constant.  We then split each ring
-	// (at theta == 0), and starting from the point of the split
-	// gradually increase both the inner and outer radii so that
-	// when we've wrapped all the way around the ring (to theta ==
-	// 2*pi), the inner radius now matches the original outer
-	// radius.  We then repeat the process with the next ring
-	// (working from innermost to outermost) until we've
-	// accumulated enough vertices to satisfy the caller's
-	// requirements.
-	//
-	// Finally, we scale and offset all the points so that the
-	// resulting spiral fits comfortably within the rectangle
-	// provided by the caller.
-
-	// Set up the array of vertices:
-	v = new float[2 * nPoints];
-	float* lastV = v + 2 * nPoints;
-
-	// Initialize the ring parameters:
-	double ringWidth = 1.0;
-	double segLength = 1.0;
-
-	float* pV = v;
-	while (pV < lastV) {
-		// Each ring consists of segments.  We'll make the arc
-		// length of each segment that lies on the inner
-		// radius approximately equal to segLength, but we'll
-		// adjust it to ensure there are an integral number of
-		// equal-sized segments in the ring.
-		int nSegments = static_cast<int>
-			(6.2831853 * innerRadius / segLength + 0.5);
-
-		double dTheta = 6.2831853 / nSegments;
-		double dRadius = ringWidth / nSegments;
-
-		double theta = 0.0;
-		for (int i = 0; i < nSegments; ++i) {
-			double c = cos(theta);
-			double s = sin(theta);
-
-			*pV++ = innerRadius * c;
-			*pV++ = innerRadius * s;
-			if (pV >= lastV)
-				break;
-
-			*pV++ = (innerRadius + ringWidth) * c;
-			*pV++ = (innerRadius + ringWidth) * s;
-			if (pV >= lastV)
-				break;
-
-			theta += dTheta;
-		}
-	}
-
-	// Find the bounding box for the spiral:
-	float lowX = FLT_MAX;
-	float highX = - FLT_MAX;
-	float lowY = FLT_MAX;
-	float highY = -FLT_MAX;
-	for (pV = v; pV < lastV; pV += 2) {
-		lowX = min(lowX, pV[0]);
-		highX = max(highX, pV[0]);
-		lowY = min(lowY, pV[1]);
-		highY = max(highY, pV[1]);
-	}
-
-	// Find scale and offset to map the spiral into the bounds supplied
-	// by our caller, with a little bit of margin around the edges:
-	lowX -= ringWidth;
-	highX += ringWidth;
-	lowY -= ringWidth;
-	highY += ringWidth;
-	float scaleX = (maxX - minX) / (highX - lowX);
-	float offsetX = minX - scaleX * lowX;
-	float scaleY = (maxY - minY) / (highY - lowY);
-	float offsetY = minY - scaleY * lowY;
-
-	// Finally scale and offset the constructed vertices so that
-	// they fit in the caller-supplied rectangle:
-	for (pV = v; pV < lastV; pV += 2) {
-		pV[0] = scaleX * pV[0] + offsetX;
-		pV[1] = scaleY * pV[1] + offsetY;
-	}
-} // SpiralStrip2D::SpiralStrip2D
-
-SpiralStrip2D::~SpiralStrip2D() {
-	delete[] v;
-} // SpiralStrip2D::~SpiralStrip2D
-
-
-
-
-///////////////////////////////////////////////////////////////////////////////
-// SpiralTri2D:  Generate (x,y) vertices for a set of independent triangles,
-//	arranged in spiral fashion exactly as in SpiralStrip2D.
-//	One may rely on the fact that SpiralTri2D generates exactly the
-//	same triangles as SpiralStrip2D, so that comparison of images
-//	using the two primitives is meaningful.
-///////////////////////////////////////////////////////////////////////////////
-SpiralTri2D::SpiralTri2D(int nTris, float minX, float maxX,
-    float minY, float maxY) {
-	SpiralStrip2D ts(nTris + 2, minX, maxX, minY, maxY);
-	const int nVertices = 3 * nTris;
-	v = new float[2 * nVertices];
-
-	float* pTris = v;
-	float* pStrip = ts(0);
-	bool front = true;	// winding order alternates in strip
-	for (int i = 0; i < nTris; ++i) {
-		if (front) {
-			pTris[0] = pStrip[0];
-			pTris[1] = pStrip[1];
-
-			pTris[2] = pStrip[2];
-			pTris[3] = pStrip[3];
-
-			pTris[4] = pStrip[4];
-			pTris[5] = pStrip[5];
-		} else {
-			pTris[0] = pStrip[0];
-			pTris[1] = pStrip[1];
-
-			pTris[2] = pStrip[4];
-			pTris[3] = pStrip[5];
-
-			pTris[4] = pStrip[2];
-			pTris[5] = pStrip[3];
-		}
-
-		front = !front;
-		pTris += 6;
-		pStrip += 2;
-	}
-} // SpiralTri2D::SpiralTri2D
-
-SpiralTri2D::~SpiralTri2D() {
-	delete[] v;
-} // SpiralTri2D::~SpiralTri2D
-
-
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Sphere3D: Forms a stacks/slices sphere and can return the vertices and index list for drawing it.
//////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/tests/glean/geomutil.h b/tests/glean/geomutil.h
index 34e7356..db899b1 100644
--- a/tests/glean/geomutil.h
+++ b/tests/glean/geomutil.h
@@ -52,26 +52,6 @@ class RandomMesh2D {
{ return m + 2 * (y * rowLength + x); }
}; // RandomMesh2D

-class SpiralStrip2D {
-	float* v;
-    public:
-	SpiralStrip2D(int nPoints, float minX, float maxX,
-		float minY, float maxY);
-	~SpiralStrip2D();
-	inline float* operator() (int i)
-		{ return v + 2 * i; }
-}; // SpiralStrip2D
-
-class SpiralTri2D {
-	float* v;
-    public:
-	SpiralTri2D(int nTris, float minX, float maxX,
-		float minY, float maxY);
-	~SpiralTri2D();
-	inline float* operator() (int i)
-		{ return v + 6 * i; }
-}; // SpiralTri2D
-
class Sphere3D {
std::vector<float> vertices;
std::vector<float> normals;
--
1.8.0.3

```