New parameter "Slicing Mode" for supporting 3DLabPrint airplane models.

S3D's strategy for merging self intersecting models is "Even / Odd"
which PrusaSlicer now supports as an alternative to "Positive" rule.
Also added a "Close Holes" option to fill in all internal structures.
3D-Labprint Models aren't sliceable (till years) #3062 #3708
This commit is contained in:
Vojtech Bubnik 2021-06-01 11:10:12 +02:00
parent df87f1b929
commit 20ba7c0a1f
12 changed files with 96 additions and 33 deletions

View file

@ -967,7 +967,7 @@ static ExPolygons make_expolygons_simple(std::vector<IntersectionLine> &lines)
return slices;
}
static void make_expolygons(const Polygons &loops, const float closing_radius, const float extra_offset, ExPolygons* slices)
static void make_expolygons(const Polygons &loops, const float closing_radius, const float extra_offset, ClipperLib::PolyFillType fill_type, ExPolygons* slices)
{
/*
Input loops are not suitable for evenodd nor nonzero fill types, as we might get
@ -1049,10 +1049,10 @@ static void make_expolygons(const Polygons &loops, const float closing_radius, c
// append to the supplied collection
expolygons_append(*slices,
offset_out > 0 && offset_in < 0 ? offset2_ex(union_ex(loops), offset_out, offset_in) :
offset_out > 0 ? offset_ex(union_ex(loops), offset_out) :
offset_in < 0 ? offset_ex(union_ex(loops), offset_in) :
union_ex(loops));
offset_out > 0 && offset_in < 0 ? offset2_ex(union_ex(loops, fill_type), offset_out, offset_in) :
offset_out > 0 ? offset_ex(union_ex(loops, fill_type), offset_out) :
offset_in < 0 ? offset_ex(union_ex(loops, fill_type), offset_in) :
union_ex(loops, fill_type));
}
std::vector<Polygons> slice_mesh(
@ -1175,9 +1175,13 @@ std::vector<ExPolygons> slice_mesh_ex(
for (size_t layer_id = range.begin(); layer_id < range.end(); ++ layer_id) {
throw_on_cancel();
ExPolygons &expolygons = layers[layer_id];
Slic3r::make_expolygons(layers_p[layer_id], params.closing_radius, params.extra_offset, &expolygons);
//FIXME simplify
const auto this_mode = layer_id < params.slicing_mode_normal_below_layer ? params.mode_below : params.mode;
Slic3r::make_expolygons(
layers_p[layer_id], params.closing_radius, params.extra_offset,
this_mode == MeshSlicingParams::SlicingMode::EvenOdd ? ClipperLib::pftEvenOdd :
this_mode == MeshSlicingParams::SlicingMode::PositiveLargestContour ? ClipperLib::pftNonZero : ClipperLib::pftPositive,
&expolygons);
//FIXME simplify
if (this_mode == MeshSlicingParams::SlicingMode::PositiveLargestContour)
keep_largest_contour_only(expolygons);
if (resolution != 0.)