Fixing large memory reservation in the SLA model slicing step.

This commit is contained in:
tamasmeszaros 2019-04-26 11:33:33 +02:00
parent 023ca6fbe6
commit 3eecf54d9c

View file

@ -674,7 +674,7 @@ void SLAPrint::process()
// Slicing the model object. This method is oversimplified and needs to
// be compared with the fff slicing algorithm for verification
auto slice_model = [this, ilhs, ilh](SLAPrintObject& po) {
auto slice_model = [this, ilhs, ilh, ilhd](SLAPrintObject& po) {
const TriangleMesh& mesh = po.transformed_mesh();
// We need to prepare the slice index...
@ -691,13 +691,15 @@ void SLAPrint::process()
auto maxZs = coord_t(maxZ / SCALING_FACTOR);
po.m_slice_index.clear();
po.m_slice_index.reserve(size_t(maxZs - (minZs + ilhs) / lhs) + 1);
po.m_slice_index.emplace_back(minZs + ilhs, float(minZ) + ilh / 2.f, ilh);
for(coord_t h = minZs + ilhs + lhs; h <= maxZs; h += lhs) {
po.m_slice_index.emplace_back(h, float(h*SCALING_FACTOR) - lh / 2.f, lh);
}
size_t cap = size_t(1 + (maxZs - minZs - ilhs) / lhs);
po.m_slice_index.reserve(cap);
po.m_slice_index.emplace_back(minZs + ilhs, minZ + ilhd / 2.0, ilh);
for(coord_t h = minZs + ilhs + lhs; h <= maxZs; h += lhs)
po.m_slice_index.emplace_back(h, h*SCALING_FACTOR - lhd / 2.0, lh);
// Just get the first record that is form the model:
auto slindex_it =
po.closest_slice_record(po.m_slice_index, float(bb3d.min(Z)));
@ -710,11 +712,8 @@ void SLAPrint::process()
po.m_model_height_levels.clear();
po.m_model_height_levels.reserve(po.m_slice_index.size());
for(auto it = slindex_it; it != po.m_slice_index.end(); ++it)
{
po.m_model_height_levels.emplace_back(it->slice_level());
}
// mesh.require_shared_vertices(); // TriangleMeshSlicer needs this
TriangleMeshSlicer slicer(&mesh);
po.m_model_slices.clear();