mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 18:05:42 +02:00
Getting more encouraging
This commit is contained in:
+22
-2
@@ -79,6 +79,23 @@ drawvec fix_by_triangulation(drawvec const &dv, int z, int detail) {
|
|||||||
while (again) {
|
while (again) {
|
||||||
again = false;
|
again = false;
|
||||||
for (size_t i = 0; i + 2 < indices.size(); i += 3) {
|
for (size_t i = 0; i + 2 < indices.size(); i += 3) {
|
||||||
|
std::vector<double> lengths;
|
||||||
|
|
||||||
|
for (size_t j = 0; j < 3; j++) {
|
||||||
|
size_t v1 = i + j;
|
||||||
|
size_t v2 = i + ((j + 1) % 3);
|
||||||
|
|
||||||
|
double dx = out[indices[v1]].x - out[indices[v2]].x;
|
||||||
|
double dy = out[indices[v1]].y - out[indices[v2]].y;
|
||||||
|
double d = sqrt(dx * dx + dy * dy);
|
||||||
|
|
||||||
|
lengths.push_back(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(lengths.begin(), lengths.end());
|
||||||
|
printf("%f %f\n", lengths[2], lengths[0]);
|
||||||
|
|
||||||
|
if (lengths[2] > 5 * lengths[0]) {
|
||||||
for (size_t j = 0; j < 3; j++) {
|
for (size_t j = 0; j < 3; j++) {
|
||||||
size_t v1 = i + j;
|
size_t v1 = i + j;
|
||||||
size_t v2 = i + ((j + 1) % 3);
|
size_t v2 = i + ((j + 1) % 3);
|
||||||
@@ -88,10 +105,12 @@ drawvec fix_by_triangulation(drawvec const &dv, int z, int detail) {
|
|||||||
std::llabs(std::llround(out[indices[v1]].y / scale) - std::llround(out[indices[v2]].y / scale)) < 2) {
|
std::llabs(std::llround(out[indices[v1]].y / scale) - std::llround(out[indices[v2]].y / scale)) < 2) {
|
||||||
double ang = atan2(out[indices[v2]].y - out[indices[v1]].y, out[indices[v2]].x - out[indices[v1]].x);
|
double ang = atan2(out[indices[v2]].y - out[indices[v1]].y, out[indices[v2]].x - out[indices[v1]].x);
|
||||||
|
|
||||||
|
double stretch = 1.5;
|
||||||
|
|
||||||
drawvec tri;
|
drawvec tri;
|
||||||
tri.emplace_back(VT_MOVETO, (long long) out[indices[v3]].x, (long long) out[indices[v3]].y);
|
tri.emplace_back(VT_MOVETO, (long long) out[indices[v3]].x, (long long) out[indices[v3]].y);
|
||||||
tri.emplace_back(VT_LINETO, out[indices[v1]].x - scale * cos(ang) * sqrt(2) * 2, out[indices[v1]].y - scale * sin(ang) * sqrt(2) * 2);
|
tri.emplace_back(VT_LINETO, out[indices[v1]].x - scale * cos(ang) * stretch, out[indices[v1]].y - scale * sin(ang) * stretch);
|
||||||
tri.emplace_back(VT_LINETO, out[indices[v2]].x + scale * cos(ang) * sqrt(2) * 2, out[indices[v2]].y + scale * sin(ang) * sqrt(2) * 2);
|
tri.emplace_back(VT_LINETO, out[indices[v2]].x + scale * cos(ang) * stretch, out[indices[v2]].y + scale * sin(ang) * stretch);
|
||||||
tri.emplace_back(VT_LINETO, (long long) out[indices[v3]].x, (long long) out[indices[v3]].y);
|
tri.emplace_back(VT_LINETO, (long long) out[indices[v3]].x, (long long) out[indices[v3]].y);
|
||||||
printf("%f\n", get_area(tri, 0, tri.size()));
|
printf("%f\n", get_area(tri, 0, tri.size()));
|
||||||
|
|
||||||
@@ -102,6 +121,7 @@ drawvec fix_by_triangulation(drawvec const &dv, int z, int detail) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < out.size(); i++) {
|
for (size_t i = 0; i < out.size(); i++) {
|
||||||
if (out[i].op == VT_MOVETO) {
|
if (out[i].op == VT_MOVETO) {
|
||||||
|
|||||||
Reference in New Issue
Block a user