mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 03:43:52 +00:00
Fix cut memory leak (#11476)
This commit is contained in:
@@ -2168,7 +2168,7 @@ static void triangulate_slice(
|
|||||||
float z,
|
float z,
|
||||||
bool triangulate,
|
bool triangulate,
|
||||||
bool normals_down,
|
bool normals_down,
|
||||||
const std::map<int, Vec3f*> §ion_vertices_map)
|
const std::map<int, Vec3f> §ion_vertices_map)
|
||||||
{
|
{
|
||||||
sort_remove_duplicates(slice_vertices);
|
sort_remove_duplicates(slice_vertices);
|
||||||
|
|
||||||
@@ -2240,7 +2240,7 @@ static void triangulate_slice(
|
|||||||
int idx = -1;
|
int idx = -1;
|
||||||
bool exist = false;
|
bool exist = false;
|
||||||
for (auto iter = section_vertices_map.begin(); iter != section_vertices_map.end(); iter++) {
|
for (auto iter = section_vertices_map.begin(); iter != section_vertices_map.end(); iter++) {
|
||||||
if (is_equal(v, *iter->second)) {
|
if (is_equal(v, iter->second)) {
|
||||||
idx = iter->first;
|
idx = iter->first;
|
||||||
exist = true;
|
exist = true;
|
||||||
break;
|
break;
|
||||||
@@ -2348,7 +2348,7 @@ void cut_mesh(const indexed_triangle_set& mesh, float z, indexed_triangle_set* u
|
|||||||
IntersectionLines upper_lines, lower_lines;
|
IntersectionLines upper_lines, lower_lines;
|
||||||
std::vector<int> upper_slice_vertices, lower_slice_vertices;
|
std::vector<int> upper_slice_vertices, lower_slice_vertices;
|
||||||
std::vector<Vec3i32> facets_edge_ids = its_face_edge_ids(mesh);
|
std::vector<Vec3i32> facets_edge_ids = its_face_edge_ids(mesh);
|
||||||
std::map<int, Vec3f *> section_vertices_map;
|
std::map<int, Vec3f> section_vertices_map;
|
||||||
|
|
||||||
for (int facet_idx = 0; facet_idx < int(mesh.indices.size()); ++ facet_idx) {
|
for (int facet_idx = 0; facet_idx < int(mesh.indices.size()); ++ facet_idx) {
|
||||||
const stl_triangle_vertex_indices &facet = mesh.indices[facet_idx];
|
const stl_triangle_vertex_indices &facet = mesh.indices[facet_idx];
|
||||||
@@ -2357,8 +2357,8 @@ void cut_mesh(const indexed_triangle_set& mesh, float z, indexed_triangle_set* u
|
|||||||
float max_z = std::max(vertices[0].z(), std::max(vertices[1].z(), vertices[2].z()));
|
float max_z = std::max(vertices[0].z(), std::max(vertices[1].z(), vertices[2].z()));
|
||||||
|
|
||||||
for (size_t i = 0; i < 3; i++) {
|
for (size_t i = 0; i < 3; i++) {
|
||||||
if (is_equal(z, vertices[i].z()) && section_vertices_map[facet(i)] == nullptr) {
|
if (is_equal(z, vertices[i].z()) && section_vertices_map.find(facet(i)) == section_vertices_map.end()) {
|
||||||
section_vertices_map[facet(i)] = new Vec3f(vertices[i].x(), vertices[i].y(), vertices[i].z());
|
section_vertices_map.emplace(facet(i), vertices[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// intersect facet with cutting plane
|
// intersect facet with cutting plane
|
||||||
@@ -2554,7 +2554,6 @@ void cut_mesh(const indexed_triangle_set& mesh, float z, indexed_triangle_set* u
|
|||||||
}
|
}
|
||||||
#endif // NDEBUG
|
#endif // NDEBUG
|
||||||
}
|
}
|
||||||
std::map<int, Vec3f*>().swap(section_vertices_map);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|||||||
Reference in New Issue
Block a user