| 659 | } |
| 660 | |
| 661 | void PathObjectTest::splitLineTest() |
| 662 | { |
| 663 | PathObject proto{Map::getCoveringRedLine()}; |
| 664 | proto.addCoordinate({0.0, 2.0}); |
| 665 | proto.addCoordinate({2.0, 0.0}); |
| 666 | proto.addCoordinate({4.0, -2.0, MapCoord::HolePoint}); |
| 667 | |
| 668 | QFETCH(int, dash_point_index); |
| 669 | if (dash_point_index >= 0) |
| 670 | proto.getCoordinateRef(std::size_t(dash_point_index)).setDashPoint(true); |
| 671 | |
| 672 | auto object_path_coord = ObjectPathCoord { &proto }; |
| 673 | auto const distance_sq = object_path_coord.findClosestPointTo({1.0, 1.0}); |
| 674 | QVERIFY(qIsNull(distance_sq)); |
| 675 | QCOMPARE(object_path_coord.pos, MapCoordF(1.0, 1.0)); |
| 676 | |
| 677 | auto const split_paths = proto.splitLineAt(object_path_coord); |
| 678 | QCOMPARE(split_paths.size(), std::size_t(2)); |
| 679 | |
| 680 | auto const *split_0 = split_paths[0]; |
| 681 | QCOMPARE(split_0->getCoordinateCount(), std::size_t(2)); |
| 682 | QCOMPARE(split_0->getCoordinate(0), proto.getCoordinate(0)); |
| 683 | QCOMPARE(split_0->getCoordinate(1), MapCoord(1.0, 1.0, MapCoord::HolePoint)); |
| 684 | delete split_0; |
| 685 | |
| 686 | auto const *split_1 = split_paths[1]; |
| 687 | QCOMPARE(split_1->getCoordinateCount(), std::size_t(3)); |
| 688 | QCOMPARE(split_1->getCoordinate(0), MapCoord(1.0, 1.0)); |
| 689 | QCOMPARE(split_1->getCoordinate(1), proto.getCoordinate(1)); |
| 690 | QCOMPARE(split_1->getCoordinate(2), proto.getCoordinate(2)); |
| 691 | delete split_1; |
| 692 | } |
| 693 | |
| 694 | |
| 695 |
nothing calls this directly
no test coverage detected