Fixed short edge collapse algortihm, so that it does not decimate all triangles on very high detailed models
Relevant issue 8834 Access Error when slicing
This commit is contained in:
parent
ec2f533e3a
commit
59fa918828
@ -663,8 +663,8 @@ void compute_global_occlusion(GlobalModelInfo &result, const PrintObject *po,
|
||||
|
||||
BOOST_LOG_TRIVIAL(debug)
|
||||
<< "SeamPlacer: decimate: start";
|
||||
its_short_edge_collpase(triangle_set, 25000);
|
||||
its_short_edge_collpase(negative_volumes_set, 25000);
|
||||
its_short_edge_collpase(triangle_set, SeamPlacer::fast_decimation_triangle_count_target);
|
||||
its_short_edge_collpase(negative_volumes_set, SeamPlacer::fast_decimation_triangle_count_target);
|
||||
|
||||
size_t negative_volumes_start_index = triangle_set.indices.size();
|
||||
its_merge(triangle_set, negative_volumes_set);
|
||||
|
@ -123,6 +123,7 @@ class SeamPlacer {
|
||||
public:
|
||||
// Number of samples generated on the mesh. There are sqr_rays_per_sample_point*sqr_rays_per_sample_point rays casted from each samples
|
||||
static constexpr size_t raycasting_visibility_samples_count = 30000;
|
||||
static constexpr size_t fast_decimation_triangle_count_target = 16000;
|
||||
//square of number of rays per sample point
|
||||
static constexpr size_t sqr_rays_per_sample_point = 5;
|
||||
|
||||
|
@ -98,6 +98,7 @@ void its_short_edge_collpase(indexed_triangle_set &mesh, size_t target_triangle_
|
||||
//shuffle the faces and traverse in random order, this MASSIVELY improves the quality of the result
|
||||
std::shuffle(face_indices.begin(), face_indices.end(), generator);
|
||||
|
||||
int allowed_face_removals = int(face_indices.size()) - int(target_triangle_count);
|
||||
for (const size_t &face_idx : face_indices) {
|
||||
if (face_removal_flags[face_idx]) {
|
||||
// if face already removed from previous collapses, skip (each collapse removes two triangles [at least] )
|
||||
@ -130,10 +131,13 @@ void its_short_edge_collpase(indexed_triangle_set &mesh, size_t target_triangle_
|
||||
// remove faces
|
||||
remove_face(face_idx, neighbor_to_remove_face_idx);
|
||||
remove_face(neighbor_to_remove_face_idx, face_idx);
|
||||
allowed_face_removals-=2;
|
||||
|
||||
// break. this triangle is done
|
||||
break;
|
||||
}
|
||||
|
||||
if (allowed_face_removals <= 0) { break; }
|
||||
}
|
||||
|
||||
// filter face_indices, remove those that have been collapsed
|
||||
|
Loading…
Reference in New Issue
Block a user