FIX:mesh's volume <0.01mm^3,should ignore
jira: STUDIO-7808 Change-Id: Ie6d1b60314cc2303c96f2f29a08eedc6ee66b06c
This commit is contained in:
parent
4bf4e1bb91
commit
438d9201fc
|
@ -39,7 +39,7 @@ static void update_bounding_box(const indexed_triangle_set &its, TriangleMeshSta
|
||||||
BoundingBoxf3 bbox = Slic3r::bounding_box(its);
|
BoundingBoxf3 bbox = Slic3r::bounding_box(its);
|
||||||
out.min = bbox.min.cast<float>();
|
out.min = bbox.min.cast<float>();
|
||||||
out.max = bbox.max.cast<float>();
|
out.max = bbox.max.cast<float>();
|
||||||
out.size = out.max - out.min;
|
out.size = out.max - out.min;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill_initial_stats(const indexed_triangle_set &its, TriangleMeshStats &out)
|
static void fill_initial_stats(const indexed_triangle_set &its, TriangleMeshStats &out)
|
||||||
|
@ -94,7 +94,7 @@ static void trianglemesh_repair_on_import(stl_file &stl)
|
||||||
stl.stats.facets_w_1_bad_edge = (stl.stats.connected_facets_2_edge - stl.stats.connected_facets_3_edge);
|
stl.stats.facets_w_1_bad_edge = (stl.stats.connected_facets_2_edge - stl.stats.connected_facets_3_edge);
|
||||||
stl.stats.facets_w_2_bad_edge = (stl.stats.connected_facets_1_edge - stl.stats.connected_facets_2_edge);
|
stl.stats.facets_w_2_bad_edge = (stl.stats.connected_facets_1_edge - stl.stats.connected_facets_2_edge);
|
||||||
stl.stats.facets_w_3_bad_edge = (stl.stats.number_of_facets - stl.stats.connected_facets_1_edge);
|
stl.stats.facets_w_3_bad_edge = (stl.stats.number_of_facets - stl.stats.connected_facets_1_edge);
|
||||||
|
|
||||||
// checking nearby
|
// checking nearby
|
||||||
//int last_edges_fixed = 0;
|
//int last_edges_fixed = 0;
|
||||||
float tolerance = (float)stl.stats.shortest_edge;
|
float tolerance = (float)stl.stats.shortest_edge;
|
||||||
|
@ -119,7 +119,7 @@ static void trianglemesh_repair_on_import(stl_file &stl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(stl_validate(&stl));
|
assert(stl_validate(&stl));
|
||||||
|
|
||||||
// remove_unconnected
|
// remove_unconnected
|
||||||
if (stl.stats.connected_facets_3_edge < (int)stl.stats.number_of_facets) {
|
if (stl.stats.connected_facets_3_edge < (int)stl.stats.number_of_facets) {
|
||||||
#ifdef SLIC3R_TRACE_REPAIR
|
#ifdef SLIC3R_TRACE_REPAIR
|
||||||
|
@ -128,7 +128,7 @@ static void trianglemesh_repair_on_import(stl_file &stl)
|
||||||
stl_remove_unconnected_facets(&stl);
|
stl_remove_unconnected_facets(&stl);
|
||||||
assert(stl_validate(&stl));
|
assert(stl_validate(&stl));
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill_holes
|
// fill_holes
|
||||||
#if 0
|
#if 0
|
||||||
// Don't fill holes, the current algorithm does more harm than good on complex holes.
|
// Don't fill holes, the current algorithm does more harm than good on complex holes.
|
||||||
|
@ -155,7 +155,7 @@ static void trianglemesh_repair_on_import(stl_file &stl)
|
||||||
#endif /* SLIC3R_TRACE_REPAIR */
|
#endif /* SLIC3R_TRACE_REPAIR */
|
||||||
stl_fix_normal_values(&stl);
|
stl_fix_normal_values(&stl);
|
||||||
assert(stl_validate(&stl));
|
assert(stl_validate(&stl));
|
||||||
|
|
||||||
// always calculate the volume and reverse all normals if volume is negative
|
// always calculate the volume and reverse all normals if volume is negative
|
||||||
#ifdef SLIC3R_TRACE_REPAIR
|
#ifdef SLIC3R_TRACE_REPAIR
|
||||||
BOOST_LOG_TRIVIAL(trace) << "\tstl_calculate_volume";
|
BOOST_LOG_TRIVIAL(trace) << "\tstl_calculate_volume";
|
||||||
|
@ -163,7 +163,7 @@ static void trianglemesh_repair_on_import(stl_file &stl)
|
||||||
// If the volume is negative, all the facets are flipped and added to stats.facets_reversed.
|
// If the volume is negative, all the facets are flipped and added to stats.facets_reversed.
|
||||||
stl_calculate_volume(&stl);
|
stl_calculate_volume(&stl);
|
||||||
assert(stl_validate(&stl));
|
assert(stl_validate(&stl));
|
||||||
|
|
||||||
// neighbors
|
// neighbors
|
||||||
#ifdef SLIC3R_TRACE_REPAIR
|
#ifdef SLIC3R_TRACE_REPAIR
|
||||||
BOOST_LOG_TRIVIAL(trace) << "\tstl_verify_neighbors";
|
BOOST_LOG_TRIVIAL(trace) << "\tstl_verify_neighbors";
|
||||||
|
@ -394,11 +394,14 @@ std::vector<TriangleMesh> TriangleMesh::split() const
|
||||||
out.reserve(itss.size());
|
out.reserve(itss.size());
|
||||||
for (indexed_triangle_set &m : itss) {
|
for (indexed_triangle_set &m : itss) {
|
||||||
// The TriangleMesh constructor shall fill in the mesh statistics including volume.
|
// The TriangleMesh constructor shall fill in the mesh statistics including volume.
|
||||||
out.emplace_back(std::move(m));
|
TriangleMesh temp_triangle_mesh(std::move(m));
|
||||||
if (TriangleMesh &triangle_mesh = out.back(); triangle_mesh.volume() < 0)
|
if (abs(temp_triangle_mesh.volume()< 0.01)) {//0.01mm^3
|
||||||
// Some source mesh parts may be incorrectly oriented. Correct them.
|
continue;
|
||||||
triangle_mesh.flip_triangles();
|
}
|
||||||
|
if (temp_triangle_mesh.volume() < 0) {// Some source mesh parts may be incorrectly oriented. Correct them.
|
||||||
|
temp_triangle_mesh.flip_triangles();
|
||||||
|
}
|
||||||
|
out.emplace_back(temp_triangle_mesh);
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -587,8 +590,8 @@ static inline std::vector<Vec3i> its_face_edge_ids_impl(const indexed_triangle_s
|
||||||
}
|
}
|
||||||
if (! found) {
|
if (! found) {
|
||||||
//FIXME Vojtech: Trying to find an edge with equal orientation. This smells.
|
//FIXME Vojtech: Trying to find an edge with equal orientation. This smells.
|
||||||
// admesh can assign the same edge ID to more than two facets (which is
|
// admesh can assign the same edge ID to more than two facets (which is
|
||||||
// still topologically correct), so we have to search for a duplicate of
|
// still topologically correct), so we have to search for a duplicate of
|
||||||
// this edge too in case it was already seen in this orientation
|
// this edge too in case it was already seen in this orientation
|
||||||
for (j = i + 1; j < edges_map.size() && edge_i == edges_map[j]; ++ j)
|
for (j = i + 1; j < edges_map.size() && edge_i == edges_map[j]; ++ j)
|
||||||
if (edges_map[j].face != -1) {
|
if (edges_map[j].face != -1) {
|
||||||
|
@ -914,7 +917,7 @@ indexed_triangle_set its_make_prism(float width, float length, float height)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate the mesh for a cylinder and return it, using
|
// Generate the mesh for a cylinder and return it, using
|
||||||
// the generated angle to calculate the top mesh triangles.
|
// the generated angle to calculate the top mesh triangles.
|
||||||
// Default is 360 sides, angle fa is in radians.
|
// Default is 360 sides, angle fa is in radians.
|
||||||
indexed_triangle_set its_make_cylinder(double r, double h, double fa)
|
indexed_triangle_set its_make_cylinder(double r, double h, double fa)
|
||||||
|
@ -1060,7 +1063,7 @@ indexed_triangle_set its_make_pyramid(float base, float height)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generates mesh for a sphere centered about the origin, using the generated angle
|
// Generates mesh for a sphere centered about the origin, using the generated angle
|
||||||
// to determine the granularity.
|
// to determine the granularity.
|
||||||
// Default angle is 1 degree.
|
// Default angle is 1 degree.
|
||||||
//FIXME better to discretize an Icosahedron recursively http://www.songho.ca/opengl/gl_sphere.html
|
//FIXME better to discretize an Icosahedron recursively http://www.songho.ca/opengl/gl_sphere.html
|
||||||
indexed_triangle_set its_make_sphere(double radius, double fa)
|
indexed_triangle_set its_make_sphere(double radius, double fa)
|
||||||
|
@ -1705,7 +1708,7 @@ float its_average_edge_length(const indexed_triangle_set &its)
|
||||||
double edge_length = 0.f;
|
double edge_length = 0.f;
|
||||||
for (size_t i = 0; i < its.indices.size(); ++ i) {
|
for (size_t i = 0; i < its.indices.size(); ++ i) {
|
||||||
const its_triangle v = its_triangle_vertices(its, i);
|
const its_triangle v = its_triangle_vertices(its, i);
|
||||||
edge_length += (v[1] - v[0]).cast<double>().norm() +
|
edge_length += (v[1] - v[0]).cast<double>().norm() +
|
||||||
(v[2] - v[0]).cast<double>().norm() +
|
(v[2] - v[0]).cast<double>().norm() +
|
||||||
(v[1] - v[2]).cast<double>().norm();
|
(v[1] - v[2]).cast<double>().norm();
|
||||||
}
|
}
|
||||||
|
@ -1787,7 +1790,7 @@ std::vector<Vec3i> its_face_neighbors_par(const indexed_triangle_set &its)
|
||||||
return create_face_neighbors_index(ex_tbb, its);
|
return create_face_neighbors_index(ex_tbb, its);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Vec3f> its_face_normals(const indexed_triangle_set &its)
|
std::vector<Vec3f> its_face_normals(const indexed_triangle_set &its)
|
||||||
{
|
{
|
||||||
std::vector<Vec3f> normals;
|
std::vector<Vec3f> normals;
|
||||||
normals.reserve(its.indices.size());
|
normals.reserve(its.indices.size());
|
||||||
|
|
Loading…
Reference in New Issue