mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 22:45:58 +08:00
algorithm fix
This commit is contained in:
parent
26bfb4e999
commit
edf0e0a144
@ -119,44 +119,35 @@ void FDMSupportSpots::find_support_areas() {
|
||||
bool visited_neighbour = false;
|
||||
|
||||
std::queue<int> neighbours { };
|
||||
for (const auto &direct_neighbour_index : current.neighbours) {
|
||||
if (direct_neighbour_index < 0 || !this->m_triangles[direct_neighbour_index].visited) {
|
||||
continue;
|
||||
}
|
||||
neighbours.push(direct_neighbour_index);
|
||||
const Triangle &direct_neighbour = this->m_triangles[direct_neighbour_index];
|
||||
if (neighbourhood_unsupported_area >= direct_neighbour.unsupported_weight) {
|
||||
neighbourhood_unsupported_area = direct_neighbour.unsupported_weight;
|
||||
group_id = direct_neighbour.group_id;
|
||||
}
|
||||
visited_neighbour = true;
|
||||
}
|
||||
|
||||
neighbours.push(current_index);
|
||||
std::set<int> explored { };
|
||||
while (!neighbours.empty() && !visited_neighbour) {
|
||||
while (!neighbours.empty() && neighbourhood_unsupported_area > 0) {
|
||||
int neighbour_index = neighbours.front();
|
||||
neighbours.pop();
|
||||
explored.insert(neighbour_index);
|
||||
|
||||
const Triangle &neighbour = this->m_triangles[neighbour_index];
|
||||
if (explored.find(neighbour_index) != explored.end()
|
||||
|| triangle_vertices_shortest_distance(this->m_mesh, current.index, neighbour_index)
|
||||
if (explored.find(neighbour_index) != explored.end()) {
|
||||
continue;
|
||||
}
|
||||
explored.insert(neighbour_index);
|
||||
if (triangle_vertices_shortest_distance(this->m_mesh, current.index, neighbour_index)
|
||||
> this->m_config.islands_tolerance_distance) {
|
||||
// not visited, already explored, or too far
|
||||
continue;
|
||||
}
|
||||
|
||||
if (neighbour.visited) {
|
||||
visited_neighbour = true;
|
||||
if (neighbourhood_unsupported_area >= neighbour.unsupported_weight) {
|
||||
neighbourhood_unsupported_area = neighbour.unsupported_weight;
|
||||
group_id = neighbour.group_id;
|
||||
}
|
||||
break;
|
||||
}
|
||||
for (const auto &neighbour_index : neighbour.neighbours) {
|
||||
if (neighbour_index < 0) {
|
||||
continue;
|
||||
}
|
||||
if (neighbour_index >= 0) {
|
||||
neighbours.push(neighbour_index);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
current.visited = true;
|
||||
|
@ -171,26 +171,28 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
|
||||
"Degree sign to use in the respective slider in FDM supports gizmo,"
|
||||
"placed after the number with no whitespace in between.");
|
||||
|
||||
std::string mm = std::string("%.f") + I18N::translate_utf8("mm");
|
||||
std::string tenth_mm = std::string("%.f") + I18N::translate_utf8(" * 0.1 (mm)");
|
||||
std::string hundreth_mm = std::string("%.f") + I18N::translate_utf8(" * 0.01 (mm)");
|
||||
|
||||
m_imgui->slider_float("##angle_threshold_deg", &m_smart_support_limit_angle_deg, 0.f, 90.f, format_str.data(),
|
||||
1.0f, true);
|
||||
m_imgui->slider_float("##patch_size", &m_smart_support_patch_size, 0.f, 20.f, mm.data(),
|
||||
m_imgui->slider_float("##patch_size", &m_smart_support_patch_size, 0.f, 100.f, tenth_mm.data(),
|
||||
1.0f, false);
|
||||
m_imgui->slider_float("##patch_spacing", &m_smart_support_patch_spacing, 0.f, 20.f, mm.data(),
|
||||
m_imgui->slider_float("##patch_spacing", &m_smart_support_patch_spacing, 0.f, 100.f, tenth_mm.data(),
|
||||
1.0f, false);
|
||||
m_imgui->slider_float("##island_tolerance", &m_smart_support_islands_tolerance, 0.f, 10.f, mm.data(),
|
||||
m_imgui->slider_float("##island_tolerance", &m_smart_support_islands_tolerance, 0.f, 100.f, hundreth_mm.data(),
|
||||
1.0f, false);
|
||||
|
||||
ImGui::NewLine();
|
||||
ImGui::SameLine(window_width - buttons_width - m_imgui->scaled(0.5f));
|
||||
if (m_imgui->button(m_desc["enforce_button"], buttons_width, 0.f)) {
|
||||
compute_smart_support_placement(m_smart_support_limit_angle_deg, m_smart_support_patch_size,
|
||||
m_smart_support_patch_spacing, m_smart_support_islands_tolerance);
|
||||
compute_smart_support_placement(m_smart_support_limit_angle_deg, m_smart_support_patch_size * 0.1f,
|
||||
m_smart_support_patch_spacing * 0.1f, m_smart_support_islands_tolerance * 0.01f);
|
||||
}
|
||||
|
||||
if (m_imgui->button(m_desc.at("remove_all"))) {
|
||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Reset selection"), UndoRedo::SnapshotType::GizmoAction);
|
||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Reset selection"),
|
||||
UndoRedo::SnapshotType::GizmoAction);
|
||||
ModelObject *mo = m_c->selection_info()->model_object();
|
||||
int idx = -1;
|
||||
for (ModelVolume *mv : mo->volumes)
|
||||
|
Loading…
x
Reference in New Issue
Block a user