mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-18 01:25:58 +08:00
Remove seam 'visit forward' assert and rename it to better convey what the function does.
This commit is contained in:
parent
114d370f92
commit
3543f8c738
@ -112,8 +112,8 @@ std::optional<std::size_t> snap_to_angle(
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}};
|
}};
|
||||||
Geometry::visit_backward(search_start, positions.size(), visitor);
|
Geometry::visit_near_backward(search_start, positions.size(), visitor);
|
||||||
Geometry::visit_forward(search_start, positions.size(), visitor);
|
Geometry::visit_near_forward(search_start, positions.size(), visitor);
|
||||||
if (match) {
|
if (match) {
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
@ -121,8 +121,8 @@ std::optional<std::size_t> snap_to_angle(
|
|||||||
min_distance = std::numeric_limits<double>::infinity();
|
min_distance = std::numeric_limits<double>::infinity();
|
||||||
angle_type = AngleType::concave;
|
angle_type = AngleType::concave;
|
||||||
|
|
||||||
Geometry::visit_backward(search_start, positions.size(), visitor);
|
Geometry::visit_near_backward(search_start, positions.size(), visitor);
|
||||||
Geometry::visit_forward(search_start, positions.size(), visitor);
|
Geometry::visit_near_forward(search_start, positions.size(), visitor);
|
||||||
|
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ Vec2d get_polygon_normal(
|
|||||||
std::optional<std::size_t> previous_index;
|
std::optional<std::size_t> previous_index;
|
||||||
std::optional<std::size_t> next_index;
|
std::optional<std::size_t> next_index;
|
||||||
|
|
||||||
visit_forward(index, points.size(), [&](const std::size_t index_candidate) {
|
visit_near_forward(index, points.size(), [&](const std::size_t index_candidate) {
|
||||||
if (index == index_candidate) {
|
if (index == index_candidate) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ Vec2d get_polygon_normal(
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
visit_backward(index, points.size(), [&](const std::size_t index_candidate) {
|
visit_near_backward(index, points.size(), [&](const std::size_t index_candidate) {
|
||||||
const double distance{(points[index_candidate] - points[index]).norm()};
|
const double distance{(points[index_candidate] - points[index]).norm()};
|
||||||
if (distance > min_arm_length) {
|
if (distance > min_arm_length) {
|
||||||
previous_index = index_candidate;
|
previous_index = index_candidate;
|
||||||
@ -204,36 +204,34 @@ std::vector<Vec2d> oversample_edge(const Vec2d &from, const Vec2d &to, const dou
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit_forward(
|
void visit_near_forward(
|
||||||
const std::size_t start_index,
|
const std::size_t start_index,
|
||||||
const std::size_t loop_size,
|
const std::size_t loop_size,
|
||||||
const std::function<bool(std::size_t)> &visitor
|
const std::function<bool(std::size_t)> &visitor
|
||||||
) {
|
) {
|
||||||
std::size_t last_index{loop_size - 1};
|
std::size_t last_index{loop_size - 1};
|
||||||
std::size_t index{start_index};
|
std::size_t index{start_index};
|
||||||
for (unsigned _{0}; _ < 30; ++_) { // Infinite loop prevention
|
for (unsigned _{0}; _ < 30; ++_) { // Do not visit too far.
|
||||||
if (visitor(index)) {
|
if (visitor(index)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
index = index == last_index ? 0 : index + 1;
|
index = index == last_index ? 0 : index + 1;
|
||||||
}
|
}
|
||||||
assert(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit_backward(
|
void visit_near_backward(
|
||||||
const std::size_t start_index,
|
const std::size_t start_index,
|
||||||
const std::size_t loop_size,
|
const std::size_t loop_size,
|
||||||
const std::function<bool(std::size_t)> &visitor
|
const std::function<bool(std::size_t)> &visitor
|
||||||
) {
|
) {
|
||||||
std::size_t last_index{loop_size - 1};
|
std::size_t last_index{loop_size - 1};
|
||||||
std::size_t index{start_index == 0 ? loop_size - 1 : start_index - 1};
|
std::size_t index{start_index == 0 ? loop_size - 1 : start_index - 1};
|
||||||
for (unsigned _{0}; _ < 30; ++_) { // Infinite loop prevention
|
for (unsigned _{0}; _ < 30; ++_) { // Do not visit too far.
|
||||||
if (visitor(index)) {
|
if (visitor(index)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
index = index == 0 ? last_index : index - 1;
|
index = index == 0 ? last_index : index - 1;
|
||||||
}
|
}
|
||||||
assert(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Vec2d> unscaled(const Points &points) {
|
std::vector<Vec2d> unscaled(const Points &points) {
|
||||||
@ -300,7 +298,7 @@ std::vector<double> get_vertex_angles(const std::vector<Vec2d> &points, const do
|
|||||||
std::optional<std::size_t> previous_index;
|
std::optional<std::size_t> previous_index;
|
||||||
std::optional<std::size_t> next_index;
|
std::optional<std::size_t> next_index;
|
||||||
|
|
||||||
visit_forward(index, points.size(), [&](const std::size_t index_candidate) {
|
visit_near_forward(index, points.size(), [&](const std::size_t index_candidate) {
|
||||||
if (index == index_candidate) {
|
if (index == index_candidate) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -311,7 +309,7 @@ std::vector<double> get_vertex_angles(const std::vector<Vec2d> &points, const do
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
visit_backward(index, points.size(), [&](const std::size_t index_candidate) {
|
visit_near_backward(index, points.size(), [&](const std::size_t index_candidate) {
|
||||||
const double distance{(points[index_candidate] - points[index]).norm()};
|
const double distance{(points[index_candidate] - points[index]).norm()};
|
||||||
if (distance > min_arm_length) {
|
if (distance > min_arm_length) {
|
||||||
previous_index = index_candidate;
|
previous_index = index_candidate;
|
||||||
|
@ -120,12 +120,12 @@ void iterate_nested(const NestedVector &nested_vector, const std::function<void(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit_forward(
|
void visit_near_forward(
|
||||||
const std::size_t start_index,
|
const std::size_t start_index,
|
||||||
const std::size_t loop_size,
|
const std::size_t loop_size,
|
||||||
const std::function<bool(std::size_t)> &visitor
|
const std::function<bool(std::size_t)> &visitor
|
||||||
);
|
);
|
||||||
void visit_backward(
|
void visit_near_backward(
|
||||||
const std::size_t start_index,
|
const std::size_t start_index,
|
||||||
const std::size_t loop_size,
|
const std::size_t loop_size,
|
||||||
const std::function<bool(std::size_t)> &visitor
|
const std::function<bool(std::size_t)> &visitor
|
||||||
|
@ -157,7 +157,7 @@ std::vector<AngleType> merge_angle_types(
|
|||||||
resulting_type = smooth_angle_type;
|
resulting_type = smooth_angle_type;
|
||||||
|
|
||||||
// Check if there is a sharp angle in the vicinity. If so, do not use the smooth angle.
|
// Check if there is a sharp angle in the vicinity. If so, do not use the smooth angle.
|
||||||
Geometry::visit_forward(index, angle_types.size(), [&](const std::size_t forward_index) {
|
Geometry::visit_near_forward(index, angle_types.size(), [&](const std::size_t forward_index) {
|
||||||
const double distance{(points[forward_index] - points[index]).norm()};
|
const double distance{(points[forward_index] - points[index]).norm()};
|
||||||
if (distance > min_arm_length) {
|
if (distance > min_arm_length) {
|
||||||
return true;
|
return true;
|
||||||
@ -167,7 +167,7 @@ std::vector<AngleType> merge_angle_types(
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
Geometry::visit_backward(index, angle_types.size(), [&](const std::size_t backward_index) {
|
Geometry::visit_near_backward(index, angle_types.size(), [&](const std::size_t backward_index) {
|
||||||
const double distance{(points[backward_index] - points[index]).norm()};
|
const double distance{(points[backward_index] - points[index]).norm()};
|
||||||
if (distance > min_arm_length) {
|
if (distance > min_arm_length) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -219,7 +219,7 @@ std::optional<Vec2d> offset_along_loop_lines(
|
|||||||
double distance{0};
|
double distance{0};
|
||||||
Vec2d previous_point{point};
|
Vec2d previous_point{point};
|
||||||
std::optional<Vec2d> offset_point;
|
std::optional<Vec2d> offset_point;
|
||||||
Geometry::visit_forward(loop_line_index, loop_lines.size(), [&](std::size_t index) {
|
Geometry::visit_near_forward(loop_line_index, loop_lines.size(), [&](std::size_t index) {
|
||||||
const Vec2d next_point{loop_lines[index].b};
|
const Vec2d next_point{loop_lines[index].b};
|
||||||
const Vec2d edge{next_point - previous_point};
|
const Vec2d edge{next_point - previous_point};
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#ifndef slic3r_GUI_WebView_hpp_
|
#ifndef slic3r_GUI_WebView_hpp_
|
||||||
#define slic3r_GUI_WebView_hpp_
|
#define slic3r_GUI_WebView_hpp_
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class wxWebView;
|
class wxWebView;
|
||||||
class wxWindow;
|
class wxWindow;
|
||||||
class wxString;
|
class wxString;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user