some bugfixes

This commit is contained in:
Patrick Brosi 2022-01-22 00:57:44 +01:00
parent 15e84d930a
commit ff8748ef3f

View file

@ -207,22 +207,34 @@ std::vector<LINE> Collector::segmentize(
size_t to = std::upper_bound(dists.begin(), dists.end(), cuts[0].second) - size_t to = std::upper_bound(dists.begin(), dists.end(), cuts[0].second) -
dists.begin(); dists.begin();
if (to >= dists.size()) to = dists.size() - 1;
POINT lastP;
if (to >= dists.size()) {
lastP = shape.back();
} else if (to == 0) {
lastP = shape.front();
} else {
double progr = (cuts[0].second - dists[to - 1]) / (dists[to] - dists[to - 1]); double progr = (cuts[0].second - dists[to - 1]) / (dists[to] - dists[to - 1]);
auto lastP = shape[to - 1]; auto lastP = shape[to - 1];
lastP.setX(lastP.getX() + progr * util::geo::dist(shape[to-1], shape[to])); lastP.setX(lastP.getX() + progr * util::geo::dist(shape[to-1], shape[to]));
lastP.setY(lastP.getY() + progr * util::geo::dist(shape[to-1], shape[to])); lastP.setY(lastP.getY() + progr * util::geo::dist(shape[to-1], shape[to]));
}
for (size_t i = 1; i < cuts.size(); i++) { for (size_t i = 1; i < cuts.size(); i++) {
size_t to = std::upper_bound(dists.begin(), dists.end(), cuts[i].second) - size_t to = std::upper_bound(dists.begin(), dists.end(), cuts[i].second) -
dists.begin(); dists.begin();
if (to >= dists.size()) to = dists.size() - 1;
POINT curP;
if (to >= dists.size()) {
curP = shape.back();
} else if (to == 0) {
curP = shape.front();
} else {
curP = shape[to - 1];
double progr = (cuts[i].second - dists[to - 1]) / (dists[to] - dists[to - 1]); double progr = (cuts[i].second - dists[to - 1]) / (dists[to] - dists[to - 1]);
// std::cout << t->getId() << ": " << dists[to] << " vs " << cuts[i].second << ", " << dists[to - 1] << " (" << progr << ")" << std::endl;
auto curP = shape[to - 1];
curP.setX(curP.getX() + progr * util::geo::dist(shape[to-1], shape[to])); curP.setX(curP.getX() + progr * util::geo::dist(shape[to-1], shape[to]));
curP.setY(curP.getY() + progr * util::geo::dist(shape[to-1], shape[to])); curP.setY(curP.getY() + progr * util::geo::dist(shape[to-1], shape[to]));
}
auto curL = pl.getSegment(lastP, curP).getLine(); auto curL = pl.getSegment(lastP, curP).getLine();