some bugfixes
This commit is contained in:
parent
15e84d930a
commit
ff8748ef3f
1 changed files with 24 additions and 12 deletions
|
@ -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;
|
|
||||||
double progr = (cuts[0].second - dists[to - 1]) / (dists[to] - dists[to - 1]);
|
POINT lastP;
|
||||||
auto lastP = shape[to - 1];
|
if (to >= dists.size()) {
|
||||||
lastP.setX(lastP.getX() + progr * util::geo::dist(shape[to-1], shape[to]));
|
lastP = shape.back();
|
||||||
lastP.setY(lastP.getY() + progr * util::geo::dist(shape[to-1], shape[to]));
|
} else if (to == 0) {
|
||||||
|
lastP = shape.front();
|
||||||
|
} else {
|
||||||
|
double progr = (cuts[0].second - dists[to - 1]) / (dists[to] - dists[to - 1]);
|
||||||
|
auto lastP = shape[to - 1];
|
||||||
|
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]));
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
double progr = (cuts[i].second - dists[to - 1]) / (dists[to] - dists[to - 1]);
|
POINT curP;
|
||||||
// std::cout << t->getId() << ": " << dists[to] << " vs " << cuts[i].second << ", " << dists[to - 1] << " (" << progr << ")" << std::endl;
|
if (to >= dists.size()) {
|
||||||
auto curP = shape[to - 1];
|
curP = shape.back();
|
||||||
curP.setX(curP.getX() + progr * util::geo::dist(shape[to-1], shape[to]));
|
} else if (to == 0) {
|
||||||
curP.setY(curP.getY() + progr * util::geo::dist(shape[to-1], shape[to]));
|
curP = shape.front();
|
||||||
|
} else {
|
||||||
|
curP = shape[to - 1];
|
||||||
|
double progr = (cuts[i].second - dists[to - 1]) / (dists[to] - dists[to - 1]);
|
||||||
|
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]));
|
||||||
|
}
|
||||||
|
|
||||||
auto curL = pl.getSegment(lastP, curP).getLine();
|
auto curL = pl.getSegment(lastP, curP).getLine();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue