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

This reverts commit 96f4c018d9.
This commit is contained in:
David Kocik 2023-05-23 11:13:06 +02:00
parent 96f4c018d9
commit 6ad9aba454
2 changed files with 5 additions and 13 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); 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")) 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); result = load_amf(input_file.c_str(), config, config_substitutions, &model, options & LoadAttribute::CheckVersion);
else if (boost::algorithm::iends_with(input_file, ".3mf") || boost::algorithm::iends_with(input_file, ".zip")) else if (boost::algorithm::iends_with(input_file, ".3mf"))
//FIXME options & LoadAttribute::CheckVersion ? //FIXME options & LoadAttribute::CheckVersion ?
result = load_3mf(input_file.c_str(), *config, *config_substitutions, &model, false); result = load_3mf(input_file.c_str(), *config, *config_substitutions, &model, false);
else else
@ -153,7 +153,7 @@ Model Model::read_from_archive(const std::string& input_file, DynamicPrintConfig
Model model; Model model;
bool result = false; bool result = false;
if (boost::algorithm::iends_with(input_file, ".3mf") || boost::algorithm::iends_with(input_file, ".zip")) if (boost::algorithm::iends_with(input_file, ".3mf"))
result = load_3mf(input_file.c_str(), *config, *config_substitutions, &model, options & LoadAttribute::CheckVersion); result = load_3mf(input_file.c_str(), *config, *config_substitutions, &model, options & LoadAttribute::CheckVersion);
else if (boost::algorithm::iends_with(input_file, ".zip.amf")) else if (boost::algorithm::iends_with(input_file, ".zip.amf"))
result = load_amf(input_file.c_str(), config, config_substitutions, &model, options & LoadAttribute::CheckVersion); result = load_amf(input_file.c_str(), config, config_substitutions, &model, options & LoadAttribute::CheckVersion);

View File

@ -1702,7 +1702,6 @@ struct Plater::priv
static const std::regex pattern_zip_amf; static const std::regex pattern_zip_amf;
static const std::regex pattern_any_amf; static const std::regex pattern_any_amf;
static const std::regex pattern_prusa; static const std::regex pattern_prusa;
static const std::regex pattern_zip;
priv(Plater *q, MainFrame *main_frame); priv(Plater *q, MainFrame *main_frame);
~priv(); ~priv();
@ -2004,7 +2003,6 @@ 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_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_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_prusa(".*prusa", std::regex::icase);
const std::regex Plater::priv::pattern_zip(".*zip", std::regex::icase);
Plater::priv::priv(Plater *q, MainFrame *main_frame) Plater::priv::priv(Plater *q, MainFrame *main_frame)
: q(q) : q(q)
@ -2491,7 +2489,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
progress_dlg->Fit(); progress_dlg->Fit();
} }
const bool type_3mf = std::regex_match(path.string(), pattern_3mf) || std::regex_match(path.string(), pattern_zip); const bool type_3mf = std::regex_match(path.string(), pattern_3mf);
const bool type_zip_amf = !type_3mf && std::regex_match(path.string(), pattern_zip_amf); 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_any_amf = !type_3mf && std::regex_match(path.string(), pattern_any_amf);
const bool type_prusa = std::regex_match(path.string(), pattern_prusa); const bool type_prusa = std::regex_match(path.string(), pattern_prusa);
@ -5927,13 +5925,7 @@ bool Plater::load_files(const wxArrayString& filenames, bool delete_after_load/*
// searches for project files // searches for project files
for (std::vector<fs::path>::const_reverse_iterator it = paths.rbegin(); it != paths.rend(); ++it) { for (std::vector<fs::path>::const_reverse_iterator it = paths.rbegin(); it != paths.rend(); ++it) {
std::string filename = (*it).filename().string(); 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; ProjectDropDialog::LoadType load_type = ProjectDropDialog::LoadType::Unknown;
{ {
if ((boost::algorithm::iends_with(filename, ".3mf") && !is_project_3mf(it->string())) || if ((boost::algorithm::iends_with(filename, ".3mf") && !is_project_3mf(it->string())) ||