ENH: plater: optimize the loading time of 3mf with large objects
JIRA: STUDIO-6021 Change-Id: Ia97f681041bb553c5c4b5b1d9109e5e5c42daf6b
This commit is contained in:
parent
07f965313a
commit
d6db3415bf
|
@ -3343,7 +3343,7 @@ void read_binary_stl(const std::string& filename, std::string& model_id, std::st
|
|||
|
||||
char protocol_version[3] = { data[3], data[4], data[5] };
|
||||
|
||||
//version
|
||||
//version
|
||||
if (protocol_version[0] != '1' || protocol_version[1] != '.' || protocol_version[2] != '0') {
|
||||
file.close();
|
||||
return;
|
||||
|
@ -4051,10 +4051,11 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
|||
q->model().load_from(model);
|
||||
load_auxiliary_files();
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format(", before load_model_objects, count %1%")%model.objects.size();
|
||||
auto loaded_idxs = load_model_objects(model.objects, is_project_file);
|
||||
obj_idxs.insert(obj_idxs.end(), loaded_idxs.begin(), loaded_idxs.end());
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format("import 3mf IMPORT_LOAD_MODEL_OBJECTS \n");
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format(", finished load_model_objects");
|
||||
wxString msg = wxString::Format(_L("Loading file: %s"), from_path(real_filename));
|
||||
dlg_cont = dlg.Update(progress_percent, msg);
|
||||
if (!dlg_cont) {
|
||||
|
@ -4066,7 +4067,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
|||
for (const ModelObject *model_object : model.objects) {
|
||||
new_model->add_object(*model_object);
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format("import 3mf IMPORT_ADD_MODEL_OBJECTS \n");
|
||||
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":" << __LINE__ << boost::format(", added object %1%")%model_object->name;
|
||||
wxString msg = wxString::Format(_L("Loading file: %s"), from_path(real_filename));
|
||||
dlg_cont = dlg.Update(progress_percent, msg);
|
||||
if (!dlg_cont) {
|
||||
|
@ -4301,6 +4302,7 @@ std::vector<size_t> Plater::priv::load_model_objects(const ModelObjectPtrs& mode
|
|||
}
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format(", loaded objects, begin to auto placement");
|
||||
#ifdef AUTOPLACEMENT_ON_LOAD
|
||||
#if 0
|
||||
// FIXME distance should be a config value /////////////////////////////////
|
||||
|
@ -4345,9 +4347,19 @@ std::vector<size_t> Plater::priv::load_model_objects(const ModelObjectPtrs& mode
|
|||
// _L("Object too large?"));
|
||||
//}
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format(", finished auto placement, before add_objects_to_list");
|
||||
notification_manager->close_notification_of_type(NotificationType::UpdatedItemsInfo);
|
||||
wxGetApp().obj_list()->add_objects_to_list(obj_idxs);
|
||||
|
||||
if (obj_idxs.size() > 1) {
|
||||
std::vector<size_t> obj_idxs_1 (obj_idxs.begin(), obj_idxs.end() - 1);
|
||||
|
||||
wxGetApp().obj_list()->add_objects_to_list(obj_idxs_1, false);
|
||||
wxGetApp().obj_list()->add_object_to_list(obj_idxs[obj_idxs.size() - 1]);
|
||||
}
|
||||
else
|
||||
wxGetApp().obj_list()->add_objects_to_list(obj_idxs);
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format(", after add_objects_to_list");
|
||||
update();
|
||||
// Update InfoItems in ObjectList after update() to use of a correct value of the GLCanvas3D::is_sinking(),
|
||||
// which is updated after a view3D->reload_scene(false, flags & (unsigned int)UpdateParams::FORCE_FULL_SCREEN_REFRESH) call
|
||||
|
@ -4381,7 +4393,7 @@ fs::path Plater::priv::get_export_file_path(GUI::FileType file_type)
|
|||
// for 3mf take the path from the project filename, if any
|
||||
output_file = into_path(get_project_filename(".3mf"));
|
||||
else if (file_type == FT_STL) {
|
||||
if (obj_idx > 0 && obj_idx < this->model.objects.size() && selection.is_single_full_object()) {
|
||||
if (obj_idx > 0 && obj_idx < this->model.objects.size() && selection.is_single_full_object()) {
|
||||
output_file = this->model.objects[obj_idx]->get_export_filename();
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue