mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Hotfix for crash with support disabled and pad enabled.
This commit is contained in:
parent
39b07e7b94
commit
52702769d4
2 changed files with 186 additions and 174 deletions
|
@ -2597,39 +2597,51 @@ void SLASupportTree::merged_mesh_with_pad(TriangleMesh &outmesh) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ExPolygons> SLASupportTree::slice(
|
std::vector<ExPolygons> SLASupportTree::slice(
|
||||||
const std::vector<float> &heights, float cr) const
|
const std::vector<float> &grid, float cr) const
|
||||||
{
|
{
|
||||||
const TriangleMesh &sup_mesh = m_impl->merged_mesh();
|
const TriangleMesh &sup_mesh = m_impl->merged_mesh();
|
||||||
const TriangleMesh &pad_mesh = get_pad();
|
const TriangleMesh &pad_mesh = get_pad();
|
||||||
|
|
||||||
std::vector<ExPolygons> sup_slices;
|
using Slices = std::vector<ExPolygons>;
|
||||||
|
auto slices = reserve_vector<Slices>(2);
|
||||||
|
|
||||||
if (!sup_mesh.empty()) {
|
if (!sup_mesh.empty()) {
|
||||||
|
slices.emplace_back();
|
||||||
|
|
||||||
TriangleMeshSlicer sup_slicer(&sup_mesh);
|
TriangleMeshSlicer sup_slicer(&sup_mesh);
|
||||||
sup_slicer.slice(heights, cr, &sup_slices, m_impl->ctl().cancelfn);
|
sup_slicer.slice(grid, cr, &slices.back(), m_impl->ctl().cancelfn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!pad_mesh.empty()) {
|
||||||
|
slices.emplace_back();
|
||||||
|
|
||||||
auto bb = pad_mesh.bounding_box();
|
auto bb = pad_mesh.bounding_box();
|
||||||
auto maxzit = std::upper_bound(heights.begin(), heights.end(), bb.max.z());
|
auto maxzit = std::upper_bound(grid.begin(), grid.end(), bb.max.z());
|
||||||
|
|
||||||
auto padgrid = reserve_vector<float>(heights.end() - maxzit);
|
auto padgrid = reserve_vector<float>(grid.end() - maxzit);
|
||||||
std::copy(heights.begin(), maxzit, std::back_inserter(padgrid));
|
std::copy(grid.begin(), maxzit, std::back_inserter(padgrid));
|
||||||
|
|
||||||
std::vector<ExPolygons> pad_slices;
|
|
||||||
if (!pad_mesh.empty()) {
|
|
||||||
TriangleMeshSlicer pad_slicer(&pad_mesh);
|
TriangleMeshSlicer pad_slicer(&pad_mesh);
|
||||||
pad_slicer.slice(padgrid, cr, &pad_slices, m_impl->ctl().cancelfn);
|
pad_slicer.slice(padgrid, cr, &slices.back(), m_impl->ctl().cancelfn);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t len = std::min(heights.size(), pad_slices.size());
|
size_t len = grid.size();
|
||||||
len = std::min(len, sup_slices.size());
|
for (const Slices slv : slices) { len = std::min(len, slv.size()); }
|
||||||
|
|
||||||
|
// Either the support or the pad or both has to be non empty
|
||||||
|
assert(!slices.empty());
|
||||||
|
|
||||||
|
Slices &mrg = slices.front();
|
||||||
|
|
||||||
|
for (auto it = std::next(slices.begin()); it != slices.end(); ++it) {
|
||||||
for (size_t i = 0; i < len; ++i) {
|
for (size_t i = 0; i < len; ++i) {
|
||||||
std::copy(pad_slices[i].begin(), pad_slices[i].end(),
|
Slices &slv = *it;
|
||||||
std::back_inserter(sup_slices[i]));
|
std::copy(slv[i].begin(), slv[i].end(), std::back_inserter(mrg[i]));
|
||||||
pad_slices[i] = {};
|
slv[i] = {}; // clear and delete
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sup_slices;
|
return mrg;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TriangleMesh &SLASupportTree::add_pad(const ExPolygons& modelbase,
|
const TriangleMesh &SLASupportTree::add_pad(const ExPolygons& modelbase,
|
||||||
|
|
|
@ -761,7 +761,7 @@ void SLAPrint::process()
|
||||||
for(coord_t h = minZs + ilhs + lhs; h <= maxZs; h += lhs)
|
for(coord_t h = minZs + ilhs + lhs; h <= maxZs; h += lhs)
|
||||||
po.m_slice_index.emplace_back(h, unscaled<float>(h) - lh / 2.f, lh);
|
po.m_slice_index.emplace_back(h, unscaled<float>(h) - lh / 2.f, lh);
|
||||||
|
|
||||||
// Just get the first record that is form the model:
|
// Just get the first record that is from the model:
|
||||||
auto slindex_it =
|
auto slindex_it =
|
||||||
po.closest_slice_record(po.m_slice_index, float(bb3d.min(Z)));
|
po.closest_slice_record(po.m_slice_index, float(bb3d.min(Z)));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue