SLA archive import will now recover the model's original position.
This commit is contained in:
parent
769ee15475
commit
8541ce4060
@ -386,7 +386,7 @@ if (NOT EXPAT_FOUND)
|
|||||||
set(EXPAT_LIBRARIES expat)
|
set(EXPAT_LIBRARIES expat)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
find_package(PNG)
|
find_package(PNG REQUIRED)
|
||||||
|
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
|
|
||||||
|
@ -162,6 +162,8 @@ void invert_raster_trafo(ExPolygons & expolys,
|
|||||||
coord_t width,
|
coord_t width,
|
||||||
coord_t height)
|
coord_t height)
|
||||||
{
|
{
|
||||||
|
if (trafo.flipXY) std::swap(height, width);
|
||||||
|
|
||||||
for (auto &expoly : expolys) {
|
for (auto &expoly : expolys) {
|
||||||
if (trafo.mirror_y)
|
if (trafo.mirror_y)
|
||||||
foreach_vertex(expoly, [height](Point &p) {p.y() = height - p.y(); });
|
foreach_vertex(expoly, [height](Point &p) {p.y() = height - p.y(); });
|
||||||
|
@ -2209,7 +2209,7 @@ void ObjectList::load_shape_object(const std::string& type_name)
|
|||||||
load_mesh_object(mesh, _(L("Shape")) + "-" + _(type_name));
|
load_mesh_object(mesh, _(L("Shape")) + "-" + _(type_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectList::load_mesh_object(const TriangleMesh &mesh, const wxString &name)
|
void ObjectList::load_mesh_object(const TriangleMesh &mesh, const wxString &name, bool center)
|
||||||
{
|
{
|
||||||
// Add mesh to model as a new object
|
// Add mesh to model as a new object
|
||||||
Model& model = wxGetApp().plater()->model();
|
Model& model = wxGetApp().plater()->model();
|
||||||
@ -2219,6 +2219,7 @@ void ObjectList::load_mesh_object(const TriangleMesh &mesh, const wxString &name
|
|||||||
#endif /* _DEBUG */
|
#endif /* _DEBUG */
|
||||||
|
|
||||||
std::vector<size_t> object_idxs;
|
std::vector<size_t> object_idxs;
|
||||||
|
auto bb = mesh.bounding_box();
|
||||||
ModelObject* new_object = model.add_object();
|
ModelObject* new_object = model.add_object();
|
||||||
new_object->name = into_u8(name);
|
new_object->name = into_u8(name);
|
||||||
new_object->add_instance(); // each object should have at list one instance
|
new_object->add_instance(); // each object should have at list one instance
|
||||||
@ -2228,13 +2229,17 @@ void ObjectList::load_mesh_object(const TriangleMesh &mesh, const wxString &name
|
|||||||
// set a default extruder value, since user can't add it manually
|
// set a default extruder value, since user can't add it manually
|
||||||
new_volume->config.set_key_value("extruder", new ConfigOptionInt(0));
|
new_volume->config.set_key_value("extruder", new ConfigOptionInt(0));
|
||||||
new_object->invalidate_bounding_box();
|
new_object->invalidate_bounding_box();
|
||||||
|
new_object->translate(-bb.center());
|
||||||
|
|
||||||
|
if (center) {
|
||||||
|
const BoundingBoxf bed_shape = wxGetApp().plater()->bed_shape_bb();
|
||||||
|
new_object->instances[0]->set_offset(Slic3r::to_3d(bed_shape.center().cast<double>(), -new_object->origin_translation(2)));
|
||||||
|
} else {
|
||||||
|
new_object->instances[0]->set_offset(bb.center());
|
||||||
|
}
|
||||||
|
|
||||||
new_object->center_around_origin();
|
|
||||||
new_object->ensure_on_bed();
|
new_object->ensure_on_bed();
|
||||||
|
|
||||||
const BoundingBoxf bed_shape = wxGetApp().plater()->bed_shape_bb();
|
|
||||||
new_object->instances[0]->set_offset(Slic3r::to_3d(bed_shape.center().cast<double>(), -new_object->origin_translation(2)));
|
|
||||||
|
|
||||||
object_idxs.push_back(model.objects.size() - 1);
|
object_idxs.push_back(model.objects.size() - 1);
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
check_model_ids_validity(model);
|
check_model_ids_validity(model);
|
||||||
|
@ -294,7 +294,7 @@ public:
|
|||||||
void load_part(ModelObject* model_object, std::vector<std::pair<wxString, bool>> &volumes_info, ModelVolumeType type);
|
void load_part(ModelObject* model_object, std::vector<std::pair<wxString, bool>> &volumes_info, ModelVolumeType type);
|
||||||
void load_generic_subobject(const std::string& type_name, const ModelVolumeType type);
|
void load_generic_subobject(const std::string& type_name, const ModelVolumeType type);
|
||||||
void load_shape_object(const std::string &type_name);
|
void load_shape_object(const std::string &type_name);
|
||||||
void load_mesh_object(const TriangleMesh &mesh, const wxString &name);
|
void load_mesh_object(const TriangleMesh &mesh, const wxString &name, bool center = true);
|
||||||
void del_object(const int obj_idx);
|
void del_object(const int obj_idx);
|
||||||
void del_subobject_item(wxDataViewItem& item);
|
void del_subobject_item(wxDataViewItem& item);
|
||||||
void del_settings_from_config(const wxDataViewItem& parent_item);
|
void del_settings_from_config(const wxDataViewItem& parent_item);
|
||||||
|
@ -219,8 +219,10 @@ void SLAImportJob::finalize()
|
|||||||
wxGetApp().load_current_presets();
|
wxGetApp().load_current_presets();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!p->mesh.empty())
|
if (!p->mesh.empty()) {
|
||||||
p->plater->sidebar().obj_list()->load_mesh_object(p->mesh, name);
|
bool is_centered = false;
|
||||||
|
p->plater->sidebar().obj_list()->load_mesh_object(p->mesh, name, is_centered);
|
||||||
|
}
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user