Commit 76eb2cf2 authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

reworked struct Triangle: struct -> typedef

parent ad5383fe
......@@ -18,12 +18,7 @@ cc2gc(double xyz[], double *lon, double *lat)
using Index = size_t;
using vec3 = std::array<double, 3>;
struct Triangle
{
Index vertex[3];
};
typedef std::array<Index,3> Triangle;
using TriangleList = std::vector<Triangle>;
using VertexList = std::vector<vec3>;
......@@ -127,11 +122,11 @@ subdivide(VertexList &vertices, TriangleList triangles)
for (auto &&each : triangles)
{
for (int edge = 0; edge < 3; ++edge)
mid[edge] = vertexForEdge(lookup, vertices, each.vertex[edge], each.vertex[(edge + 1) % 3]);
mid[edge] = vertexForEdge(lookup, vertices, each[edge], each[(edge + 1) % 3]);
result.push_back({ each.vertex[0], mid[0], mid[2] });
result.push_back({ each.vertex[1], mid[1], mid[0] });
result.push_back({ each.vertex[2], mid[2], mid[1] });
result.push_back({ each[0], mid[0], mid[2] });
result.push_back({ each[1], mid[1], mid[0] });
result.push_back({ each[2], mid[2], mid[1] });
result.push_back({ mid[0], mid[1], mid[2] });
}
......@@ -236,10 +231,10 @@ genIcosphereCoords(int subdivisions, bool lbounds, std::vector<double> &xvals, s
size_t i = 0;
for (Triangle &t : triangles)
{
vec3 center = circumCenterMean(vertices[t.vertex[0]], vertices[t.vertex[1]], vertices[t.vertex[2]]);
vec3 center = circumCenterMean(vertices[t[0]], vertices[t[1]], vertices[t[2]]);
cc2gc(&center[0], &xvals[i], &yvals[i]);
if (lbounds)
for (size_t k = 0; k < 3; ++k) cc2gc(&vertices[t.vertex[k]][0], &xbounds[i * 3 + k], &ybounds[i * 3 + k]);
for (size_t k = 0; k < 3; ++k) cc2gc(&vertices[t[k]][0], &xbounds[i * 3 + k], &ybounds[i * 3 + k]);
i++;
}
......@@ -269,12 +264,12 @@ main(void)
}
for (Triangle &t : triangles)
{
fprintf(stderr, "index: %d %d %d\n", t.vertex[0], t.vertex[1], t.vertex[2]);
fprintf(stderr, "index: %d %d %d\n", t[0], t[1], t[2]);
}
for (Triangle &t : triangles)
{
double lon, lat;
vec3 center = circumCenterMean(vertices[t.vertex[0]], vertices[t.vertex[1]], vertices[t.vertex[2]]);
vec3 center = circumCenterMean(vertices[t[0]], vertices[t[1]], vertices[t[2]]);
cc2gc(&center[0], &lon, &lat);
fprintf(stderr, "center: %g %g\n", rad2deg(lon), rad2deg(lat));
}
......@@ -284,10 +279,10 @@ main(void)
printf(">\n");
for (int i = 0; i < 3; ++i)
{
cc2gc(&vertices[t.vertex[i]][0], &lon, &lat);
cc2gc(&vertices[t[i]][0], &lon, &lat);
printf(" %g %g\n", rad2deg(lon), rad2deg(lat));
}
cc2gc(&vertices[t.vertex[0]][0], &lon, &lat);
cc2gc(&vertices[t[0]][0], &lon, &lat);
printf(" %g %g\n", rad2deg(lon), rad2deg(lat));
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment