Skip to content

Commit

Permalink
Merge branch 'master_slic3rPE_PR'
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Dec 7, 2018
2 parents 9396b63 + 4b76c7d commit 2eab8fd
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 5 deletions.
4 changes: 3 additions & 1 deletion xs/src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1011,8 +1011,10 @@ PrintConfigDef::PrintConfigDef()
def->cli = "infill-dense-algo=s";
def->enum_keys_map = &ConfigOptionEnum<DenseInfillAlgo>::get_enum_values();
def->enum_values.push_back("automatic");
def->enum_values.push_back("enxtended");
def->enum_values.push_back("autosmall");
def->enum_values.push_back("enlarged");
def->enum_labels.push_back(L("Automatic"));
def->enum_labels.push_back(L("Automatic, only for small areas"));
def->enum_labels.push_back(L("Anchored"));
def->default_value = new ConfigOptionEnum<DenseInfillAlgo>(dfaAutomatic);

Expand Down
3 changes: 2 additions & 1 deletion xs/src/libslic3r/PrintConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ enum FilamentType {
};

enum DenseInfillAlgo {
dfaAutomatic, dfaEnlarged,
dfaAutomatic, dfaAutoNotFull, dfaEnlarged,
};

template<> inline t_config_enum_values& ConfigOptionEnum<GCodeFlavor>::get_enum_values() {
Expand Down Expand Up @@ -145,6 +145,7 @@ template<> inline t_config_enum_values& ConfigOptionEnum<DenseInfillAlgo>::get_e
static t_config_enum_values keys_map;
if (keys_map.empty()) {
keys_map["automatic"] = dfaAutomatic;
keys_map["autosmall"] = dfaAutoNotFull;
keys_map["enlarged"] = dfaEnlarged;
}
return keys_map;
Expand Down
72 changes: 69 additions & 3 deletions xs/src/libslic3r/PrintObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,15 @@ void PrintObject::count_distance_solid() {
uint64_t area_intersect = 0;
for (ExPolygon poly_inter : intersect) area_intersect += poly_inter.area();
//if it's in a dense area and the current surface isn't a dense one yet and the not-dense is too small.
if (surf.area() > area_intersect * COEFF_SPLIT &&
std::cout << idx_layer << " dfaEnlarged: " << layerm->region()->config.infill_dense_algo << "\n";
std::cout << idx_layer << " dfaEnlarged: 1-" << (layerm->region()->config.infill_dense_algo == dfaEnlarged) << "\n";
std::cout << idx_layer << " dfaEnlarged: 2-" << (surf.area() > area_intersect * COEFF_SPLIT) << "\n";
std::cout << idx_layer << " dfaEnlarged: 3-" << (surf.maxNbSolidLayersOnTop > nb_dense_layers) << "\n";
std::cout << idx_layer << " dfaEnlarged: surf.area()=" << unscale(unscale(surf.area())) << ", area_intersect=" << unscale(unscale(area_intersect)) << "\n";
std::cout << idx_layer << " dfaEnlarged: surf.maxNbSolidLayersOnTop=" << surf.maxNbSolidLayersOnTop << ", NB_DENSE_LAYERS=" << NB_DENSE_LAYERS << "\n";
if ((surf.area() > area_intersect * COEFF_SPLIT) &&
surf.maxNbSolidLayersOnTop > nb_dense_layers) {
std::cout << idx_layer << " split in two: " << "\n";
//split in two
if (dist == 1) {
//if just under the solid area, we can expand a bit
Expand Down Expand Up @@ -577,7 +584,7 @@ void PrintObject::count_distance_solid() {
} else {
surf.maxNbSolidLayersOnTop = std::min(surf.maxNbSolidLayersOnTop, dist);
}
} else if (layerm->region()->config.infill_dense_algo == dfaAutomatic) {
} else if (layerm->region()->config.infill_dense_algo == dfaAutoNotFull || layerm->region()->config.infill_dense_algo == dfaAutomatic) {
double area_intersect = 0;
for (ExPolygon poly_inter : intersect) area_intersect += poly_inter.area();
//like intersect.empty() but more resilient
Expand All @@ -586,7 +593,7 @@ void PrintObject::count_distance_solid() {
if (dist <= NB_DENSE_LAYERS) {
// it will be a dense infill, split the surface if needed
//if the not-dense is too big to do a full dense and the current surface isn't a dense one yet.
if (surf.area() > area_intersect * COEFF_SPLIT &&
if ((layerm->region()->config.infill_dense_algo == dfaAutomatic || surf.area() > area_intersect * COEFF_SPLIT) &&
surf.maxNbSolidLayersOnTop > NB_DENSE_LAYERS) {
//split in two
if (dist == 1) {
Expand Down Expand Up @@ -628,6 +635,65 @@ void PrintObject::count_distance_solid() {
surf.maxNbSolidLayersOnTop = std::min(surf.maxNbSolidLayersOnTop, dist);
}
}
} else if (layerm->region()->config.infill_dense_algo == dfaAutomatic) {
double area_intersect = 0;
for (ExPolygon poly_inter : intersect) area_intersect += poly_inter.area();
std::cout << idx_layer << " dfaAutomatic: area_intersect=" << unscale(unscale(area_intersect)) << "\n";
//like intersect.empty() but more resilient
if (area_intersect > layerm->flow(frInfill).scaled_width() * layerm->flow(frInfill).scaled_width() * 2) {
std::cout << idx_layer << " dfaAutomatic: ok\n";
uint16_t dist = (uint16_t)(upp.maxNbSolidLayersOnTop + 1);
if (dist <= NB_DENSE_LAYERS) {
std::cout << idx_layer << " dfaAutomatic: dist=" << dist << "\n";
// it will be a dense infill, split the surface if needed
//if the not-dense is too big to do a full dense and the current surface isn't a dense one yet.
if (surf.maxNbSolidLayersOnTop > NB_DENSE_LAYERS) {
std::cout << idx_layer << " dfaAutomatic: surf.maxNbSolidLayersOnTop=" << surf.maxNbSolidLayersOnTop << "\n";
//split in two
if (dist == 1) {
//if just under the solid area, we can expand a bit
ExPolygons cover_intersect;
for (ExPolygon &expoly_tocover : intersect) {
std::cout << idx_layer << " dfaAutomatic: fit_to_size\n";
ExPolygons temp = (fit_to_size(expoly_tocover, expoly_tocover,
diff_ex(offset_ex(layerm->fill_no_overlap_expolygons, layerm->flow(frInfill).scaled_width()),
offset_ex(layerm->fill_no_overlap_expolygons, -layerm->flow(frInfill).scaled_width())),
surf.expolygon,
4 * layerm->flow(frInfill).scaled_width(), 0.01));
cover_intersect.insert(cover_intersect.end(), temp.begin(), temp.end());
}
intersect = offset_ex(cover_intersect,
layerm->flow(frInfill).scaled_width());// +scale_(expandby));
//layerm->region()->config.external_infill_margin));
} else {
std::cout << "dfaAutomatic: remove too small sections\n";
//just remove too small sections
intersect = offset_ex(intersect,
layerm->flow(frInfill).scaled_width());
}
if (!intersect.empty()) {
ExPolygons sparse_surfaces = offset2_ex(
diff_ex(sparse_polys, intersect, true),
-layerm->flow(frInfill).scaled_width(),
layerm->flow(frInfill).scaled_width());
ExPolygons dense_surfaces = diff_ex(sparse_polys, sparse_surfaces, true);
//assign (copy)
sparse_polys.clear();
sparse_polys.insert(sparse_polys.begin(), sparse_surfaces.begin(), sparse_surfaces.end());
dense_polys.insert(dense_polys.end(), dense_surfaces.begin(), dense_surfaces.end());
dense_dist = std::min(dense_dist, dist);
std::cout << "dfaAutomatic: assign\n";
}
} else {
std::cout << "dfaAutomatic: set dist ?" << (area_intersect < layerm->flow(frInfill).scaled_width() * layerm->flow(frInfill).scaled_width() * 2) << " (1)\n";
if (area_intersect < layerm->flow(frInfill).scaled_width() * layerm->flow(frInfill).scaled_width() * 2)
surf.maxNbSolidLayersOnTop = std::min(surf.maxNbSolidLayersOnTop, dist);
}
} else {
std::cout << "dfaAutomatic: set dist (2)\n";
surf.maxNbSolidLayersOnTop = std::min(surf.maxNbSolidLayersOnTop, dist);
}
}
}
}
}
Expand Down

0 comments on commit 2eab8fd

Please sign in to comment.