Eradicated admesh from TriangleMesh:

TriangleMesh newly only holds indexed_triangle_set and
TriangleMeshStats. TriangleMeshStats contains an excerpt of stl_stats.
TriangleMeshStats are updated when initializing with indexed_triangle_set.

Admesh triangle mesh fixing is newly only used when loading an STL.
AMF / 3MF / OBJ file formats are already indexed triangle sets, thus
they are no more converted to admesh stl_file format, nor fixed
through admesh repair machinery. When importing AMF / 3MF / OBJ files,
volume is calculated and if negative, all faces are flipped. Also
a bounding box and number of open edges is calculated.

Implemented its_number_of_patches(), its_num_open_edges()
Optimized its_split(), its_is_splittable() using a visitor pattern.

Reworked QHull integration into TriangleMesh:
    1) Face normals were not right.
    2) Indexed triangle set is newly emitted instead of duplicating
       vertices for each face.

Fixed cut_mesh(): Orient the triangulated faces correctly.
This commit is contained in:
Vojtech Bubnik 2021-09-20 17:12:22 +02:00
parent f484953a5a
commit 8a2a9dba2f
59 changed files with 1056 additions and 1758 deletions

View file

@ -1135,7 +1135,7 @@ void Sidebar::show_info_sizer()
static_cast<int>(model_object->facets_count()), stats.number_of_parts));
int errors = stats.degenerate_facets + stats.edges_fixed + stats.facets_removed +
stats.facets_added + stats.facets_reversed + stats.backwards_edges;
stats.facets_reversed + stats.backwards_edges;
if (errors > 0) {
wxString tooltip = format_wxstr(_L_PLURAL("Auto-repaired %1$d error", "Auto-repaired %1$d errors", errors), errors);
p->object_info->info_manifold->SetLabel(tooltip);
@ -1147,8 +1147,6 @@ void Sidebar::show_info_sizer()
tooltip += format_wxstr(_L_PLURAL("%1$d edge fixed", "%1$d edges fixed", stats.edges_fixed), stats.edges_fixed) + ", ";
if (stats.facets_removed > 0)
tooltip += format_wxstr(_L_PLURAL("%1$d facet removed", "%1$d facets removed", stats.facets_removed), stats.facets_removed) + ", ";
if (stats.facets_added > 0)
tooltip += format_wxstr(_L_PLURAL("%1$d facet added", "%1$d facets added", stats.facets_added), stats.facets_added) + ", ";
if (stats.facets_reversed > 0)
tooltip += format_wxstr(_L_PLURAL("%1$d facet reversed", "%1$d facets reversed", stats.facets_reversed), stats.facets_reversed) + ", ";
if (stats.backwards_edges > 0)
@ -2544,16 +2542,14 @@ std::vector<size_t> Plater::priv::load_model_objects(const ModelObjectPtrs& mode
if (max_ratio > 10000) {
// the size of the object is too big -> this could lead to overflow when moving to clipper coordinates,
// so scale down the mesh
double inv = 1. / max_ratio;
object->scale_mesh_after_creation(inv * Vec3d::Ones());
object->scale_mesh_after_creation(1. / max_ratio);
object->origin_translation = Vec3d::Zero();
object->center_around_origin();
scaled_down = true;
break;
}
else if (max_ratio > 5) {
const Vec3d inverse = 1.0 / max_ratio * Vec3d::Ones();
instance->set_scaling_factor(inverse.cwiseProduct(instance->get_scaling_factor()));
instance->set_scaling_factor(instance->get_scaling_factor() / max_ratio);
scaled_down = true;
}
}
@ -5587,11 +5583,9 @@ void Plater::export_stl(bool extended, bool selection_only)
for (const ModelVolume *v : mo->volumes)
if (v->is_model_part()) {
TriangleMesh vol_mesh(v->mesh());
vol_mesh.repair();
vol_mesh.transform(v->get_matrix(), true);
mesh.merge(vol_mesh);
}
mesh.repair();
if (instances) {
TriangleMesh vols_mesh(mesh);
mesh = TriangleMesh();
@ -5601,7 +5595,6 @@ void Plater::export_stl(bool extended, bool selection_only)
mesh.merge(m);
}
}
mesh.repair();
return mesh;
};