Check if object's size appears to be zero, when loading the model file.
This commit is contained in:
parent
7340488aaf
commit
c15be26bff
@ -513,6 +513,22 @@ void Model::convert_from_meters(bool only_small_volumes)
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr const double zero_volume = 0.0000000001;
|
||||
|
||||
int Model::removed_objects_with_zero_volume()
|
||||
{
|
||||
if (objects.size() == 0)
|
||||
return 0;
|
||||
|
||||
int removed = 0;
|
||||
for (int i = int(objects.size()) - 1; i >= 0; i--)
|
||||
if (objects[i]->get_object_stl_stats().volume < zero_volume) {
|
||||
delete_object(size_t(i));
|
||||
removed++;
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
void Model::adjust_min_z()
|
||||
{
|
||||
if (objects.empty())
|
||||
|
@ -1124,6 +1124,7 @@ public:
|
||||
void convert_from_imperial_units(bool only_small_volumes);
|
||||
bool looks_like_saved_in_meters() const;
|
||||
void convert_from_meters(bool only_small_volumes);
|
||||
int removed_objects_with_zero_volume();
|
||||
|
||||
// Ensures that the min z of the model is not negative
|
||||
void adjust_min_z();
|
||||
|
@ -2438,6 +2438,14 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||
};
|
||||
|
||||
if (!is_project_file) {
|
||||
if (int deleted_objects = model.removed_objects_with_zero_volume(); deleted_objects > 0) {
|
||||
MessageDialog(q, format_wxstr(_L_PLURAL(
|
||||
"Object size from file %s appears to be zero.\n"
|
||||
"This object has been removed from the model",
|
||||
"Objects size from file %s appear to be zero.\n"
|
||||
"These objects have been removed from the model", deleted_objects), from_path(filename)) + "\n",
|
||||
_L("Object size is zero"), wxICON_INFORMATION | wxOK).ShowModal();
|
||||
}
|
||||
if (imperial_units)
|
||||
// Convert even if the object is big.
|
||||
convert_from_imperial_units(model, false);
|
||||
|
Loading…
Reference in New Issue
Block a user