Concider projects with .zip extension that are 3mf projects as it would have .3mf extension.

This commit is contained in:
David Kocik 2023-05-23 11:13:06 +02:00
parent 115195fb8e
commit 96f4c018d9
2 changed files with 13 additions and 5 deletions

View File

@ -119,7 +119,7 @@ Model Model::read_from_file(const std::string& input_file, DynamicPrintConfig* c
result = load_step(input_file.c_str(), &model);
else if (boost::algorithm::iends_with(input_file, ".amf") || boost::algorithm::iends_with(input_file, ".amf.xml"))
result = load_amf(input_file.c_str(), config, config_substitutions, &model, options & LoadAttribute::CheckVersion);
else if (boost::algorithm::iends_with(input_file, ".3mf"))
else if (boost::algorithm::iends_with(input_file, ".3mf") || boost::algorithm::iends_with(input_file, ".zip"))
//FIXME options & LoadAttribute::CheckVersion ?
result = load_3mf(input_file.c_str(), *config, *config_substitutions, &model, false);
else
@ -153,7 +153,7 @@ Model Model::read_from_archive(const std::string& input_file, DynamicPrintConfig
Model model;
bool result = false;
if (boost::algorithm::iends_with(input_file, ".3mf"))
if (boost::algorithm::iends_with(input_file, ".3mf") || boost::algorithm::iends_with(input_file, ".zip"))
result = load_3mf(input_file.c_str(), *config, *config_substitutions, &model, options & LoadAttribute::CheckVersion);
else if (boost::algorithm::iends_with(input_file, ".zip.amf"))
result = load_amf(input_file.c_str(), config, config_substitutions, &model, options & LoadAttribute::CheckVersion);

View File

@ -1702,6 +1702,7 @@ struct Plater::priv
static const std::regex pattern_zip_amf;
static const std::regex pattern_any_amf;
static const std::regex pattern_prusa;
static const std::regex pattern_zip;
priv(Plater *q, MainFrame *main_frame);
~priv();
@ -2003,6 +2004,7 @@ const std::regex Plater::priv::pattern_3mf(".*3mf", std::regex::icase);
const std::regex Plater::priv::pattern_zip_amf(".*[.]zip[.]amf", std::regex::icase);
const std::regex Plater::priv::pattern_any_amf(".*[.](amf|amf[.]xml|zip[.]amf)", std::regex::icase);
const std::regex Plater::priv::pattern_prusa(".*prusa", std::regex::icase);
const std::regex Plater::priv::pattern_zip(".*zip", std::regex::icase);
Plater::priv::priv(Plater *q, MainFrame *main_frame)
: q(q)
@ -2489,7 +2491,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
progress_dlg->Fit();
}
const bool type_3mf = std::regex_match(path.string(), pattern_3mf);
const bool type_3mf = std::regex_match(path.string(), pattern_3mf) || std::regex_match(path.string(), pattern_zip);
const bool type_zip_amf = !type_3mf && std::regex_match(path.string(), pattern_zip_amf);
const bool type_any_amf = !type_3mf && std::regex_match(path.string(), pattern_any_amf);
const bool type_prusa = std::regex_match(path.string(), pattern_prusa);
@ -5925,7 +5927,13 @@ bool Plater::load_files(const wxArrayString& filenames, bool delete_after_load/*
// searches for project files
for (std::vector<fs::path>::const_reverse_iterator it = paths.rbegin(); it != paths.rend(); ++it) {
std::string filename = (*it).filename().string();
if (boost::algorithm::iends_with(filename, ".3mf") || boost::algorithm::iends_with(filename, ".amf")) {
bool handle_as_project = (boost::algorithm::iends_with(filename, ".3mf") || boost::algorithm::iends_with(filename, ".amf"));
if (boost::algorithm::iends_with(filename, ".zip") && is_project_3mf(it->string())) {
BOOST_LOG_TRIVIAL(warning) << "File with .zip extension is 3mf project, opening as it would have .3mf extension: " << *it;
handle_as_project = true;
}
if (handle_as_project) {
ProjectDropDialog::LoadType load_type = ProjectDropDialog::LoadType::Unknown;
{
if ((boost::algorithm::iends_with(filename, ".3mf") && !is_project_3mf(it->string())) ||