mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-01 15:41:58 +08:00
FIX> infinite loop because intersection is out of line
place on line mast be perpendicular to source line but NOT to edge
This commit is contained in:
parent
b6ee9f4368
commit
d6616be202
@ -967,11 +967,9 @@ std::pair<Slic3r::Point, Slic3r::Point> VoronoiGraphUtils::point_on_lines(
|
|||||||
bool is_linear = edge->is_linear();
|
bool is_linear = edge->is_linear();
|
||||||
|
|
||||||
Point edge_point = create_edge_point(position);
|
Point edge_point = create_edge_point(position);
|
||||||
Point dir = to_point(edge->vertex0()) - to_point(edge->vertex1());
|
|
||||||
Line intersecting_line(edge_point, edge_point + PointUtils::perp(dir));
|
|
||||||
|
|
||||||
auto point_on_line = [&](const VD::edge_type *edge) -> Point {
|
auto point_on_line = [&](const VD::edge_type *edge) -> Point {
|
||||||
assert(edge->is_finite());
|
assert(edge->is_finite());
|
||||||
const VD::cell_type *cell = edge->cell();
|
const VD::cell_type *cell = edge->cell();
|
||||||
size_t line_index = cell->source_index();
|
size_t line_index = cell->source_index();
|
||||||
const Line &line = lines[line_index];
|
const Line &line = lines[line_index];
|
||||||
@ -984,6 +982,9 @@ std::pair<Slic3r::Point, Slic3r::Point> VoronoiGraphUtils::point_on_lines(
|
|||||||
if (cell->source_category() == SOURCE_CATEGORY_SEGMENT_END_POINT) {
|
if (cell->source_category() == SOURCE_CATEGORY_SEGMENT_END_POINT) {
|
||||||
return line.b;
|
return line.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Point dir = LineUtils::direction(line);
|
||||||
|
Line intersecting_line(edge_point, edge_point + PointUtils::perp(dir));
|
||||||
std::optional<Vec2d> intersection = LineUtils::intersection(line, intersecting_line);
|
std::optional<Vec2d> intersection = LineUtils::intersection(line, intersecting_line);
|
||||||
assert(intersection.has_value());
|
assert(intersection.has_value());
|
||||||
return intersection->cast<coord_t>();
|
return intersection->cast<coord_t>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user