Merge branch 'master' of https://github.com/Prusa3d/PrusaSlicer
This commit is contained in:
commit
9b700ef252
5 changed files with 199 additions and 177 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto bb = pad_mesh.bounding_box();
|
|
||||||
auto maxzit = std::upper_bound(heights.begin(), heights.end(), bb.max.z());
|
|
||||||
|
|
||||||
auto padgrid = reserve_vector<float>(heights.end() - maxzit);
|
|
||||||
std::copy(heights.begin(), maxzit, std::back_inserter(padgrid));
|
|
||||||
|
|
||||||
std::vector<ExPolygons> pad_slices;
|
|
||||||
if (!pad_mesh.empty()) {
|
if (!pad_mesh.empty()) {
|
||||||
|
slices.emplace_back();
|
||||||
|
|
||||||
|
auto bb = pad_mesh.bounding_box();
|
||||||
|
auto maxzit = std::upper_bound(grid.begin(), grid.end(), bb.max.z());
|
||||||
|
|
||||||
|
auto padgrid = reserve_vector<float>(grid.end() - maxzit);
|
||||||
|
std::copy(grid.begin(), maxzit, std::back_inserter(padgrid));
|
||||||
|
|
||||||
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()); }
|
||||||
|
|
||||||
for (size_t i = 0; i < len; ++i) {
|
// Either the support or the pad or both has to be non empty
|
||||||
std::copy(pad_slices[i].begin(), pad_slices[i].end(),
|
assert(!slices.empty());
|
||||||
std::back_inserter(sup_slices[i]));
|
|
||||||
pad_slices[i] = {};
|
Slices &mrg = slices.front();
|
||||||
|
|
||||||
|
for (auto it = std::next(slices.begin()); it != slices.end(); ++it) {
|
||||||
|
for (size_t i = 0; i < len; ++i) {
|
||||||
|
Slices &slv = *it;
|
||||||
|
std::copy(slv[i].begin(), slv[i].end(), std::back_inserter(mrg[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)));
|
||||||
|
|
||||||
|
|
|
@ -2921,7 +2921,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
&& m_gizmos.get_current_type() != GLGizmosManager::SlaSupports) // disable context menu when the gizmo is open
|
&& m_gizmos.get_current_type() != GLGizmosManager::SlaSupports) // disable context menu when the gizmo is open
|
||||||
{
|
{
|
||||||
// forces the selection of the volume
|
// forces the selection of the volume
|
||||||
m_selection.add(volume_idx);
|
/* m_selection.add(volume_idx); // #et_FIXME_if_needed
|
||||||
|
* To avoid extra "Add-Selection" snapshots,
|
||||||
|
* call add() with check_for_already_contained=true
|
||||||
|
* */
|
||||||
|
m_selection.add(volume_idx, true, true);
|
||||||
m_gizmos.refresh_on_off_state();
|
m_gizmos.refresh_on_off_state();
|
||||||
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
|
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
|
||||||
m_gizmos.update_data();
|
m_gizmos.update_data();
|
||||||
|
|
|
@ -2646,7 +2646,6 @@ void Plater::priv::reset()
|
||||||
|
|
||||||
void Plater::priv::mirror(Axis axis)
|
void Plater::priv::mirror(Axis axis)
|
||||||
{
|
{
|
||||||
this->take_snapshot(_(L("Mirror")));
|
|
||||||
view3D->mirror_selection(axis);
|
view3D->mirror_selection(axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1475,7 +1475,14 @@ void Selection::toggle_instance_printable_state()
|
||||||
if ((0 <= instance_idx) && (instance_idx < (int)model_object->instances.size()))
|
if ((0 <= instance_idx) && (instance_idx < (int)model_object->instances.size()))
|
||||||
{
|
{
|
||||||
ModelInstance* instance = model_object->instances[instance_idx];
|
ModelInstance* instance = model_object->instances[instance_idx];
|
||||||
instance->printable = !instance->printable;
|
const bool printable = !instance->printable;
|
||||||
|
|
||||||
|
wxString snapshot_text = model_object->instances.size() == 1 ? wxString::Format("%s %s",
|
||||||
|
printable ? _(L("Set Printable")) : _(L("Set Unprintable")), model_object->name) :
|
||||||
|
printable ? _(L("Set Printable Instance")) : _(L("Set Unprintable Instance"));
|
||||||
|
wxGetApp().plater()->take_snapshot(snapshot_text);
|
||||||
|
|
||||||
|
instance->printable = printable;
|
||||||
|
|
||||||
for (GLVolume* volume : *m_volumes)
|
for (GLVolume* volume : *m_volumes)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue