Export STL exports hollowed & drilled mesh (if it is shown)

This commit is contained in:
Lukas Matena 2020-02-11 00:58:19 +01:00
parent 94d3ca7016
commit 6d0cf16797

View file

@ -4893,14 +4893,14 @@ void Plater::export_stl(bool extended, bool selection_only)
wxBusyCursor wait;
TriangleMesh mesh;
if (selection_only) {
const auto &selection = p->get_selection();
if (selection.is_wipe_tower()) { return; }
const auto obj_idx = selection.get_object_idx();
if (obj_idx == -1) { return; }
if (selection_only && (obj_idx == -1 || selection.is_wipe_tower()))
return;
TriangleMesh mesh;
if (p->printer_technology == ptFFF) {
if (selection_only) {
const ModelObject* model_object = p->model.objects[obj_idx];
if (selection.get_mode() == Selection::Instance)
{
@ -4917,21 +4917,29 @@ void Plater::export_stl(bool extended, bool selection_only)
mesh.translate(-model_object->origin_translation.cast<float>());
}
}
else {
mesh = p->model.mesh();
}
}
else
{
mesh = p->model.mesh();
// This is SLA mode, all objects have only one volume.
// However, we must have a look at the backend to load
// hollowed mesh and/or supports
if (extended && (p->printer_technology == ptSLA))
{
const PrintObjects& objects = p->sla_print.objects();
for (const SLAPrintObject* object : objects)
{
const ModelObject* model_object = object->model_object();
if (selection_only) {
if (model_object->id() != p->model.objects[obj_idx]->id())
continue;
}
Transform3d mesh_trafo_inv = object->trafo().inverse();
bool is_left_handed = object->is_left_handed();
TriangleMesh pad_mesh;
bool has_pad_mesh = object->has_mesh(slaposPad);
bool has_pad_mesh = extended && object->has_mesh(slaposPad);
if (has_pad_mesh)
{
pad_mesh = object->get_mesh(slaposPad);
@ -4939,7 +4947,7 @@ void Plater::export_stl(bool extended, bool selection_only)
}
TriangleMesh supports_mesh;
bool has_supports_mesh = object->has_mesh(slaposSupportTree);
bool has_supports_mesh = extended && object->has_mesh(slaposSupportTree);
if (has_supports_mesh)
{
supports_mesh = object->get_mesh(slaposSupportTree);
@ -4955,8 +4963,12 @@ void Plater::export_stl(bool extended, bool selection_only)
if (it != model_object->instances.end())
{
bool one_inst_only = selection_only && ! selection.is_single_full_object();
int instance_idx = it - model_object->instances.begin();
const Transform3d& inst_transform = object->model_object()->instances[instance_idx]->get_transformation().get_matrix();
const Transform3d& inst_transform = one_inst_only
? Transform3d::Identity()
: object->model_object()->instances[instance_idx]->get_transformation().get_matrix();
if (has_pad_mesh)
{
@ -4971,7 +4983,15 @@ void Plater::export_stl(bool extended, bool selection_only)
inst_supports_mesh.transform(inst_transform, is_left_handed);
mesh.merge(inst_supports_mesh);
}
}
TriangleMesh inst_object_mesh = object->get_mesh_to_print();
inst_object_mesh.translate(0.f, 0.f, -object->get_elevation());
inst_object_mesh.transform(inst_transform, is_left_handed);
mesh.merge(inst_object_mesh);
if (one_inst_only)
break;
}
}
}