mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-04 17:35:42 +02:00
Getting more encouraging
This commit is contained in:
+32
-12
@@ -79,24 +79,44 @@ 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++) {
|
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);
|
||||||
size_t v3 = i + ((j + 2) % 3);
|
|
||||||
|
|
||||||
if (std::llabs(std::llround(out[indices[v1]].x / scale) - std::llround(out[indices[v2]].x / scale)) < 2 &&
|
double dx = out[indices[v1]].x - out[indices[v2]].x;
|
||||||
std::llabs(std::llround(out[indices[v1]].y / scale) - std::llround(out[indices[v2]].y / scale)) < 2) {
|
double dy = out[indices[v1]].y - out[indices[v2]].y;
|
||||||
double ang = atan2(out[indices[v2]].y - out[indices[v1]].y, out[indices[v2]].x - out[indices[v1]].x);
|
double d = sqrt(dx * dx + dy * dy);
|
||||||
|
|
||||||
drawvec tri;
|
lengths.push_back(d);
|
||||||
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[v2]].x + scale * cos(ang) * sqrt(2) * 2, out[indices[v2]].y + scale * sin(ang) * sqrt(2) * 2);
|
|
||||||
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()));
|
|
||||||
|
|
||||||
for (auto const &d : tri) {
|
std::sort(lengths.begin(), lengths.end());
|
||||||
out2.push_back(d);
|
printf("%f %f\n", lengths[2], lengths[0]);
|
||||||
|
|
||||||
|
if (lengths[2] > 5 * lengths[0]) {
|
||||||
|
for (size_t j = 0; j < 3; j++) {
|
||||||
|
size_t v1 = i + j;
|
||||||
|
size_t v2 = i + ((j + 1) % 3);
|
||||||
|
size_t v3 = i + ((j + 2) % 3);
|
||||||
|
|
||||||
|
if (std::llabs(std::llround(out[indices[v1]].x / scale) - std::llround(out[indices[v2]].x / 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 stretch = 1.5;
|
||||||
|
|
||||||
|
drawvec tri;
|
||||||
|
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) * stretch, out[indices[v1]].y - scale * sin(ang) * stretch);
|
||||||
|
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);
|
||||||
|
printf("%f\n", get_area(tri, 0, tri.size()));
|
||||||
|
|
||||||
|
for (auto const &d : tri) {
|
||||||
|
out2.push_back(d);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user