ENH:Add 'Don't show again' to the step mesh

jira: STUDIO-8606
Change-Id: I2382b9052e2c994a458ad36ca61eb94c517927c6
(cherry picked from commit 0cce6619ce12aa8540f6dfca6d9ee79ffba65c19)
This commit is contained in:
Mack
2024-11-08 21:06:57 +08:00
committed by Noisyfox
parent 65e5b193e1
commit 0bc2444079
10 changed files with 154 additions and 76 deletions

View File

@@ -177,18 +177,67 @@ Model::~Model()
Slic3r::remove_backup(*this, true);
}
Model Model::read_from_step(const std::string& input_file,
LoadStrategy options,
ImportStepProgressFn stepFn,
StepIsUtf8Fn stepIsUtf8Fn,
std::function<int(Slic3r::Step&, double&, double&)> step_mesh_fn,
double linear_defletion,
double angle_defletion)
{
Model model;
bool result = false;
bool is_cb_cancel = false;
std::string message;
Step step_file(input_file);
step_file.load();
if (step_mesh_fn) {
if (step_mesh_fn(step_file, linear_defletion, angle_defletion) == -1) {
Model empty_model;
return empty_model;
}
}
result = load_step(input_file.c_str(), &model, is_cb_cancel, linear_defletion, angle_defletion, stepFn, stepIsUtf8Fn);
if (is_cb_cancel) {
Model empty_model;
return empty_model;
}
if (!result) {
if (message.empty())
throw Slic3r::RuntimeError(_L("Loading of a model file failed."));
else
throw Slic3r::RuntimeError(message);
}
if (model.objects.empty())
throw Slic3r::RuntimeError(_L("The supplied file couldn't be read because it's empty"));
for (ModelObject *o : model.objects)
o->input_file = input_file;
if (options & LoadStrategy::AddDefaultInstances)
model.add_default_instances();
return model;
}
// BBS: add part plate related logic
// BBS: backup & restore
// Loading model from a file, it may be a simple geometry file as STL or OBJ, however it may be a project file as well.
Model Model::read_from_file(const std::string& input_file, DynamicPrintConfig* config, ConfigSubstitutionContext* config_substitutions,
LoadStrategy options, PlateDataPtrs* plate_data, std::vector<Preset*>* project_presets, bool *is_xxx, Semver* file_version, Import3mfProgressFn proFn,
ImportstlProgressFn stlFn,
ImportStepProgressFn stepFn,
StepIsUtf8Fn stepIsUtf8Fn,
BBLProject * project,
int plate_id,
ObjImportColorFn objFn,
std::function<int(Slic3r::Step&, double&, double&)> step_mesh_fn)
Model Model::read_from_file(const std::string& input_file,
DynamicPrintConfig* config,
ConfigSubstitutionContext* config_substitutions,
LoadStrategy options,
PlateDataPtrs* plate_data,
std::vector<Preset*>* project_presets,
bool *is_xxx,
Semver* file_version,
Import3mfProgressFn proFn,
ImportstlProgressFn stlFn,
BBLProject * project,
int plate_id,
ObjImportColorFn objFn)
{
Model model;
@@ -212,20 +261,7 @@ Model Model::read_from_file(const std::string& input_file, DynamicPrintConfig* c
bool result = false;
bool is_cb_cancel = false;
std::string message;
if (boost::algorithm::iends_with(input_file, ".stp") ||
boost::algorithm::iends_with(input_file, ".step")) {
double linear_defletion = 0.003;
double angle_defletion = 0.5;
Step step_file(input_file);
step_file.load();
if (step_mesh_fn) {
if (step_mesh_fn(step_file, linear_defletion, angle_defletion) == -1) {
Model empty_model;
return empty_model;
}
}
result = load_step(input_file.c_str(), &model, is_cb_cancel, linear_defletion, angle_defletion, stepFn, stepIsUtf8Fn);
} else if (boost::algorithm::iends_with(input_file, ".stl"))
if (boost::algorithm::iends_with(input_file, ".stl"))
result = load_stl(input_file.c_str(), &model, nullptr, stlFn);
else if (boost::algorithm::iends_with(input_file, ".oltp"))
result = load_stl(input_file.c_str(), &model, nullptr, stlFn,256);