Skip to content

Commit

Permalink
some littles fixes (import, y ordering)
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Feb 24, 2024
2 parents 858f66f + 10f8d5c commit dd1cc46
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
22 changes: 12 additions & 10 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1248,16 +1248,18 @@ static inline std::vector<const PrintInstance*> sort_object_instances_by_max_y(c
instances.emplace_back(&object->instances()[i]);
// Calculate the convex hull of a printable object.
Polygon poly = object->model_object()->convex_hull_2d(
Geometry::assemble_transform(Vec3d::Zero(),
object->instances()[i].model_instance->get_rotation(),
object->instances()[i].model_instance->get_scaling_factor(),
object->instances()[i].model_instance->get_mirror()));
poly.translate(object->instances()[i].shift - object->center_offset());
coord_t min_y = poly.first_point().y();
for (const Point& point : poly.points)
if (point.y() < min_y)
min_y = point.y();
map_min_y[instances.back()] = min_y;
object->trafo()
// already in object->trafo()
//* Geometry::assemble_transform(Vec3d::Zero(),
// object->instances()[i].model_instance->get_rotation(),
// object->instances()[i].model_instance->get_scaling_factor(),
// object->instances()[i].model_instance->get_mirror())
);
BoundingBox bb(poly.points);
Vec2crd offset = object->instances()[i].shift - object->center_offset();
bb.translate(offset.x(), offset.y());
std::cout<<"bbobj (mod*inst) "<<i<<" : x:"<<unscaled(bb.min.x())<<"->"<<unscaled(bb.max.x())<<" ; y:"<<unscaled(bb.min.y())<<"->"<<unscaled(bb.max.y())<<"\n";
map_min_y[instances.back()] = bb.min.y();
}
}
std::sort(instances.begin(), instances.end(), [&map_min_y](const PrintInstance* po1, const PrintInstance* po2) { return map_min_y[po1] < map_min_y[po2]; });
Expand Down
4 changes: 4 additions & 0 deletions src/slic3r/GUI/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ static void add_config_substitutions(const ConfigSubstitutions& conf_substitutio

bool is_infill = def->opt_key == "top_fill_pattern" ||
def->opt_key == "bottom_fill_pattern" ||
def->opt_key == "solid_fill_pattern" ||
def->opt_key == "bridge_fill_pattern" ||
def->opt_key == "support_material_interface_pattern" ||
def->opt_key == "brim_ears_pattern" ||
def->opt_key == "fill_pattern";

// Each infill doesn't use all list of infill declared in PrintConfig.hpp.
Expand Down
9 changes: 5 additions & 4 deletions src/slic3r/GUI/Plater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2416,7 +2416,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_

auto *nozzle_dmrs = config->opt<ConfigOptionFloats>("nozzle_diameter");

bool one_by_one = input_files.size() == 1 || printer_technology == ptSLA || nozzle_dmrs->values.size() <= 1;
bool one_by_one = input_files.size() == 1 || printer_technology == ptSLA; // || nozzle_dmrs->values.size() <= 1; // removed by bb (toa llow multi-import on a single extruder printer.
if (! one_by_one) {
for (const auto &path : input_files) {
if (std::regex_match(path.string(), pattern_bundle)) {
Expand Down Expand Up @@ -2729,10 +2729,11 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_

if (new_model != nullptr && new_model->objects.size() > 1) {
//wxMessageDialog msg_dlg(q, _L(
MessageDialog msg_dlg(q, _L(
MessageDialog msg_dlg(q, nozzle_dmrs->values.size() > 1 ? _L(
"Multiple objects were loaded for a multi-material printer.\n"
"Instead of considering them as multiple objects, should I consider\n"
"these files to represent a single object having multiple parts?") + "\n",
"these files to represent a single object having multiple parts?") + "\n":
_L("Load these files as a single object with multiple parts?\n"),
_L("Multi-part object detected"), wxICON_WARNING | wxYES | wxNO);
if (msg_dlg.ShowModal() == wxID_YES) {
new_model->convert_multipart_object(nozzle_dmrs->values.size());
Expand Down Expand Up @@ -5519,7 +5520,7 @@ bool Plater::load_files(const wxArrayString& filenames)
std::string filename = (*it).filename().string();
if (boost::algorithm::iends_with(filename, ".3mf") || boost::algorithm::iends_with(filename, ".amf")) {
LoadType load_type = LoadType::Unknown;
if (!model().objects.empty()) {
if (!model().objects.empty() || wxGetApp().app_config->get("show_drop_project_dialog") == "1") {
if ((boost::algorithm::iends_with(filename, ".3mf") && !is_project_3mf(it->string())) ||
(boost::algorithm::iends_with(filename, ".amf") && !boost::algorithm::iends_with(filename, ".zip.amf")))
load_type = LoadType::LoadGeometry;
Expand Down

0 comments on commit dd1cc46

Please sign in to comment.