convert a boost ring to vertices
| 478 | |
| 479 | // convert a boost ring to vertices |
| 480 | std::vector<Point3d> verticesFromBoostRing(const BoostRing& ring, std::vector<Point3d>& allPoints, double tol) { |
| 481 | std::vector<Point3d> result; |
| 482 | |
| 483 | // add point for each vertex except final vertex |
| 484 | for (unsigned i = 0; i < ring.size() - 1; ++i) { |
| 485 | const Point3d point3d(ring[i].x(), ring[i].y(), 0.0); |
| 486 | |
| 487 | // try to combine points within tolerance |
| 488 | Point3d resultPoint = getCombinedPoint(point3d, allPoints, tol); |
| 489 | |
| 490 | // don't keep repeated vertices |
| 491 | if ((i > 0) && (result.back() == resultPoint)) { |
| 492 | continue; |
| 493 | } |
| 494 | result.emplace_back(std::move(resultPoint)); |
| 495 | } |
| 496 | |
| 497 | result = removeCollinearLegacy(result); |
| 498 | |
| 499 | // don't keep repeated vertices |
| 500 | if (result.front() == result.back()) { |
| 501 | result.pop_back(); |
| 502 | } |
| 503 | |
| 504 | if (result.size() < 3) { |
| 505 | return {}; |
| 506 | } |
| 507 | |
| 508 | return result; |
| 509 | } |
| 510 | |
| 511 | // struct used to sort polygons in descending order by area |
| 512 | struct BoostPolygonAreaGreater |
nothing calls this directly
no test coverage detected