diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 8659e6961..1ade36e36 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -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()) diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index 6e0063f1b..11cbdc0cf 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -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(); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 68c20d497..0710c0916 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2438,6 +2438,14 @@ std::vector Plater::priv::load_files(const std::vector& 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);