cut_mesh(): new parameter to optionally not triangulate the caps.
This commit is contained in:
parent
66cf7ea9d3
commit
e952aded78
2 changed files with 33 additions and 28 deletions
|
@ -1179,6 +1179,7 @@ std::vector<ExPolygons> slice_mesh_ex(
|
|||
return layers;
|
||||
}
|
||||
|
||||
// Remove duplicates of slice_vertices, optionally triangulate the cut.
|
||||
static void triangulate_slice(
|
||||
indexed_triangle_set &its,
|
||||
IntersectionLines &lines,
|
||||
|
@ -1186,7 +1187,8 @@ static void triangulate_slice(
|
|||
// Vertices of the original (unsliced) mesh. Newly added vertices are those on the slice.
|
||||
int num_original_vertices,
|
||||
// Z height of the slice.
|
||||
float z)
|
||||
float z,
|
||||
bool triangulate)
|
||||
{
|
||||
sort_remove_duplicates(slice_vertices);
|
||||
|
||||
|
@ -1230,6 +1232,7 @@ static void triangulate_slice(
|
|||
f(i) = map_duplicate_vertex[f(i) - num_original_vertices];
|
||||
}
|
||||
|
||||
if (triangulate) {
|
||||
size_t idx_vertex_new_first = its.vertices.size();
|
||||
Pointf3s triangles = triangulate_expolygons_3d(make_expolygons_simple(lines), z, true);
|
||||
for (size_t i = 0; i < triangles.size(); ) {
|
||||
|
@ -1258,6 +1261,7 @@ static void triangulate_slice(
|
|||
if (facet(0) != facet(1) && facet(0) != facet(2) && facet(1) != facet(2))
|
||||
its.indices.emplace_back(facet);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove vertices, which are not referenced by any face.
|
||||
its_compactify_vertices(its);
|
||||
|
@ -1266,7 +1270,7 @@ static void triangulate_slice(
|
|||
// its_remove_degenerate_faces(its);
|
||||
}
|
||||
|
||||
void cut_mesh(const indexed_triangle_set &mesh, float z, indexed_triangle_set *upper, indexed_triangle_set *lower)
|
||||
void cut_mesh(const indexed_triangle_set &mesh, float z, indexed_triangle_set *upper, indexed_triangle_set *lower, bool triangulate_caps)
|
||||
{
|
||||
assert(upper || lower);
|
||||
if (upper == nullptr && lower == nullptr)
|
||||
|
@ -1413,10 +1417,10 @@ void cut_mesh(const indexed_triangle_set &mesh, float z, indexed_triangle_set *u
|
|||
}
|
||||
|
||||
if (upper != nullptr)
|
||||
triangulate_slice(*upper, upper_lines, upper_slice_vertices, int(mesh.vertices.size()), z);
|
||||
triangulate_slice(*upper, upper_lines, upper_slice_vertices, int(mesh.vertices.size()), z, triangulate_caps);
|
||||
|
||||
if (lower != nullptr)
|
||||
triangulate_slice(*lower, lower_lines, lower_slice_vertices, int(mesh.vertices.size()), z);
|
||||
triangulate_slice(*lower, lower_lines, lower_slice_vertices, int(mesh.vertices.size()), z, triangulate_caps);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -76,7 +76,8 @@ void cut_mesh(
|
|||
const indexed_triangle_set &mesh,
|
||||
float z,
|
||||
indexed_triangle_set *upper,
|
||||
indexed_triangle_set *lower);
|
||||
indexed_triangle_set *lower,
|
||||
bool triangulate_caps = true);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue