mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
Export to STL of SLA supports and pad
This commit is contained in:
parent
4a5992ba6e
commit
a3385278e5
5 changed files with 95 additions and 15 deletions
|
@ -2925,7 +2925,7 @@ bool Plater::priv::init_common_menu(wxMenu* menu, const bool is_part/* = false*/
|
|||
[this](wxCommandEvent&) { reload_from_disk(); });
|
||||
|
||||
append_menu_item(menu, wxID_ANY, _(L("Export as STL")) + dots, _(L("Export the selected object as STL file")),
|
||||
[this](wxCommandEvent&) { q->export_stl(true); });
|
||||
[this](wxCommandEvent&) { q->export_stl(false, true); });
|
||||
|
||||
menu->AppendSeparator();
|
||||
}
|
||||
|
@ -3431,7 +3431,7 @@ void Plater::export_gcode()
|
|||
p->export_gcode(std::move(output_path), PrintHostJob());
|
||||
}
|
||||
|
||||
void Plater::export_stl(bool selection_only)
|
||||
void Plater::export_stl(bool extended, bool selection_only)
|
||||
{
|
||||
if (p->model.objects.empty()) { return; }
|
||||
|
||||
|
@ -3466,8 +3466,65 @@ void Plater::export_stl(bool selection_only)
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh = p->model.mesh();
|
||||
|
||||
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();
|
||||
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(slaposBasePool);
|
||||
if (has_pad_mesh)
|
||||
{
|
||||
pad_mesh = object->get_mesh(slaposBasePool);
|
||||
pad_mesh.transform(mesh_trafo_inv);
|
||||
}
|
||||
|
||||
TriangleMesh supports_mesh;
|
||||
bool has_supports_mesh = object->has_mesh(slaposSupportTree);
|
||||
if (has_supports_mesh)
|
||||
{
|
||||
supports_mesh = object->get_mesh(slaposSupportTree);
|
||||
supports_mesh.transform(mesh_trafo_inv);
|
||||
}
|
||||
|
||||
const std::vector<SLAPrintObject::Instance>& obj_instances = object->instances();
|
||||
for (const SLAPrintObject::Instance& obj_instance : obj_instances)
|
||||
{
|
||||
auto it = std::find_if(model_object->instances.begin(), model_object->instances.end(),
|
||||
[&obj_instance](const ModelInstance *mi) { return mi->id() == obj_instance.instance_id; });
|
||||
assert(it != model_object->instances.end());
|
||||
|
||||
if (it != model_object->instances.end())
|
||||
{
|
||||
int instance_idx = it - model_object->instances.begin();
|
||||
const Transform3d& inst_transform = object->model_object()->instances[instance_idx]->get_transformation().get_matrix();
|
||||
|
||||
if (has_pad_mesh)
|
||||
{
|
||||
TriangleMesh inst_pad_mesh = pad_mesh;
|
||||
inst_pad_mesh.transform(inst_transform, is_left_handed);
|
||||
mesh.merge(inst_pad_mesh);
|
||||
}
|
||||
|
||||
if (has_supports_mesh)
|
||||
{
|
||||
TriangleMesh inst_supports_mesh = supports_mesh;
|
||||
inst_supports_mesh.transform(inst_transform, is_left_handed);
|
||||
mesh.merge(inst_supports_mesh);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Slic3r::store_stl(path_u8.c_str(), &mesh, true);
|
||||
p->statusbar()->set_status_text(wxString::Format(_(L("STL file exported to %s")), path));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue