mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 22:45:58 +08:00
fix multipart object progress bar
This commit is contained in:
parent
39535e03bd
commit
92397007fe
@ -19,7 +19,7 @@ set(SOURCES
|
|||||||
src/Kernel/graph.cpp
|
src/Kernel/graph.cpp
|
||||||
src/Kernel/point.cpp
|
src/Kernel/point.cpp
|
||||||
src/Kernel/jqsort.cpp
|
src/Kernel/jqsort.cpp
|
||||||
src/MeshFix/meshfix.cpp
|
# src/MeshFix/meshfix.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -35,7 +35,7 @@ namespace Slic3r {
|
|||||||
class RepairCanceledException: public std::exception {
|
class RepairCanceledException: public std::exception {
|
||||||
public:
|
public:
|
||||||
const char* what() const throw () {
|
const char* what() const throw () {
|
||||||
return "Model repair has been canceled";
|
return "Model repair has been cancelled";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -281,50 +281,52 @@ bool fix_model_by_meshfix(ModelObject &model_object, int volume_idx, wxProgressD
|
|||||||
meshes_repaired.reserve(volumes.size());
|
meshes_repaired.reserve(volumes.size());
|
||||||
for (ModelVolume *mv : volumes) {
|
for (ModelVolume *mv : volumes) {
|
||||||
std::vector<indexed_triangle_set> parts = its_split(mv->mesh().its);
|
std::vector<indexed_triangle_set> parts = its_split(mv->mesh().its);
|
||||||
|
unsigned percent_per_part = 95 / parts.size();
|
||||||
for (size_t part_idx = 0; part_idx < parts.size(); ++part_idx) {
|
for (size_t part_idx = 0; part_idx < parts.size(); ++part_idx) {
|
||||||
|
unsigned progress_part_base = part_idx * percent_per_part;
|
||||||
|
|
||||||
detail::Basic_TMesh_Adapter tin { };
|
detail::Basic_TMesh_Adapter tin { };
|
||||||
on_progress(L("Loading source model"), 0);
|
on_progress(L("Loading source model"), progress_part_base);
|
||||||
if (canceled)
|
if (canceled)
|
||||||
throw RepairCanceledException();
|
throw RepairCanceledException();
|
||||||
tin.load_indexed_triangle_set(parts[part_idx]);
|
tin.load_indexed_triangle_set(parts[part_idx]);
|
||||||
tin.boundaries();
|
tin.boundaries();
|
||||||
on_progress(L("Join closest components"), 10);
|
on_progress(L("Join closest components"), unsigned(progress_part_base + 0.1 * percent_per_part));
|
||||||
if (canceled)
|
if (canceled)
|
||||||
throw RepairCanceledException();
|
throw RepairCanceledException();
|
||||||
joinClosestComponents(&tin);
|
joinClosestComponents(&tin);
|
||||||
tin.deselectTriangles();
|
tin.deselectTriangles();
|
||||||
tin.boundaries();
|
tin.boundaries();
|
||||||
// Keep only the largest component (i.e. with most triangles)
|
// Keep only the largest component (i.e. with most triangles)
|
||||||
on_progress(L("Remove smallest components"), 20);
|
on_progress(L("Remove smallest components"), unsigned(progress_part_base + 0.2 * percent_per_part));
|
||||||
if (canceled)
|
if (canceled)
|
||||||
throw RepairCanceledException();
|
throw RepairCanceledException();
|
||||||
tin.removeSmallestComponents();
|
tin.removeSmallestComponents();
|
||||||
|
|
||||||
// Fill holes
|
// Fill holes
|
||||||
on_progress(L("Check holes"), 30);
|
on_progress(L("Check holes"), unsigned(progress_part_base + 0.3 * percent_per_part));
|
||||||
if (canceled)
|
if (canceled)
|
||||||
throw RepairCanceledException();
|
throw RepairCanceledException();
|
||||||
if (tin.boundaries()) {
|
if (tin.boundaries()) {
|
||||||
on_progress(L("Patch small holes"), 40);
|
on_progress(L("Patch small holes"), unsigned(progress_part_base + 0.4 * percent_per_part));
|
||||||
if (canceled)
|
if (canceled)
|
||||||
throw RepairCanceledException();
|
throw RepairCanceledException();
|
||||||
tin.fillSmallBoundaries(0, true);
|
tin.fillSmallBoundaries(0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
on_progress(L("Geometry check"), 50);
|
on_progress(L("Geometry check"), unsigned(progress_part_base + 0.5 * percent_per_part));
|
||||||
if (canceled)
|
if (canceled)
|
||||||
throw RepairCanceledException();
|
throw RepairCanceledException();
|
||||||
// Run geometry correction
|
// Run geometry correction
|
||||||
if (!tin.boundaries()) {
|
if (!tin.boundaries()) {
|
||||||
int iteration = 0;
|
int iteration = 0;
|
||||||
on_progress(L("Iterative geometry correction"), 55);
|
on_progress(L("Start iterative correction"), unsigned(progress_part_base + 0.55 * percent_per_part));
|
||||||
tin.deselectTriangles();
|
tin.deselectTriangles();
|
||||||
tin.invertSelection();
|
tin.invertSelection();
|
||||||
bool fixed = false;
|
bool fixed = false;
|
||||||
while (iteration < 10 && !fixed) { //default constants taken from TMesh library
|
while (iteration < 10 && !fixed) { //default constants taken from TMesh library
|
||||||
fixed = tin.meshclean_single_iteration(3, canceled);
|
fixed = tin.meshclean_single_iteration(3, canceled);
|
||||||
on_progress(L("Fixing geometry"), std::min(95, 60 + iteration * 8)); // majority of objects should finish in 4 iterations
|
on_progress(L("Fixing geometry"), progress_part_base + percent_per_part * std::min(0.9, 0.6 + iteration*0.08)); // majority of objects should finish in 4 iterations
|
||||||
if (canceled)
|
if (canceled)
|
||||||
throw RepairCanceledException();
|
throw RepairCanceledException();
|
||||||
iteration++;
|
iteration++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user