mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-24 07:03:59 -06:00
Fix of previous infill refactoring.
This commit is contained in:
parent
246dc64c99
commit
413e737d7e
1 changed files with 50 additions and 15 deletions
|
@ -116,7 +116,7 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
|
||||||
has_internal_voids = true;
|
has_internal_voids = true;
|
||||||
else {
|
else {
|
||||||
FlowRole extrusion_role = (surface.surface_type == stTop) ? frTopSolidInfill : (surface.is_solid() ? frSolidInfill : frInfill);
|
FlowRole extrusion_role = (surface.surface_type == stTop) ? frTopSolidInfill : (surface.is_solid() ? frSolidInfill : frInfill);
|
||||||
bool is_bridge = layerm.layer()->id() > 0 && surface.is_bridge();
|
bool is_bridge = layer.id() > 0 && surface.is_bridge();
|
||||||
params.extruder = layerm.region()->extruder(extrusion_role);
|
params.extruder = layerm.region()->extruder(extrusion_role);
|
||||||
params.pattern = layerm.region()->config().fill_pattern.value;
|
params.pattern = layerm.region()->config().fill_pattern.value;
|
||||||
params.density = float(layerm.region()->config().fill_density);
|
params.density = float(layerm.region()->config().fill_density);
|
||||||
|
@ -141,11 +141,11 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
|
||||||
// calculate the actual flow we'll be using for this infill
|
// calculate the actual flow we'll be using for this infill
|
||||||
params.flow = layerm.region()->flow(
|
params.flow = layerm.region()->flow(
|
||||||
extrusion_role,
|
extrusion_role,
|
||||||
(surface.thickness == -1) ? layerm.layer()->height : surface.thickness, // extrusion height
|
(surface.thickness == -1) ? layer.height : surface.thickness, // extrusion height
|
||||||
is_bridge || Fill::use_bridge_flow(params.pattern), // bridge flow?
|
is_bridge || Fill::use_bridge_flow(params.pattern), // bridge flow?
|
||||||
layerm.layer()->id() == 0, // first layer?
|
layer.id() == 0, // first layer?
|
||||||
-1, // auto width
|
-1, // auto width
|
||||||
*layerm.layer()->object()
|
*layer.object()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Calculate flow spacing for infill pattern generation.
|
// Calculate flow spacing for infill pattern generation.
|
||||||
|
@ -156,7 +156,7 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
|
||||||
// layer height
|
// layer height
|
||||||
params.spacing = layerm.region()->flow(
|
params.spacing = layerm.region()->flow(
|
||||||
frInfill,
|
frInfill,
|
||||||
layerm.layer()->object()->config().layer_height.value, // TODO: handle infill_every_layers?
|
layer.object()->config().layer_height.value, // TODO: handle infill_every_layers?
|
||||||
false, // no bridge
|
false, // no bridge
|
||||||
false, // no first layer
|
false, // no first layer
|
||||||
-1, // auto width
|
-1, // auto width
|
||||||
|
@ -199,12 +199,14 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
|
||||||
Polygons all_polygons;
|
Polygons all_polygons;
|
||||||
for (SurfaceFill &fill : surface_fills)
|
for (SurfaceFill &fill : surface_fills)
|
||||||
if (! fill.expolygons.empty()) {
|
if (! fill.expolygons.empty()) {
|
||||||
Polygons polys = to_polygons(std::move(fill.expolygons));
|
if (fill.expolygons.size() > 1 || ! all_polygons.empty()) {
|
||||||
if (fill.expolygons.size() > 1 || ! all_polygons.empty())
|
Polygons polys = to_polygons(std::move(fill.expolygons));
|
||||||
// Make a union of polygons, use a safety offset, subtract the preceding polygons.
|
// Make a union of polygons, use a safety offset, subtract the preceding polygons.
|
||||||
// Bridges are processed first (see SurfaceFill::operator<())
|
// Bridges are processed first (see SurfaceFill::operator<())
|
||||||
fill.expolygons = all_polygons.empty() ? union_ex(polys, true) : diff_ex(polys, all_polygons, true);
|
fill.expolygons = all_polygons.empty() ? union_ex(polys, true) : diff_ex(polys, all_polygons, true);
|
||||||
append(all_polygons, std::move(polys));
|
append(all_polygons, std::move(polys));
|
||||||
|
} else if (&fill != &surface_fills.back())
|
||||||
|
append(all_polygons, to_polygons(fill.expolygons));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +261,7 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
|
||||||
region_id = region_some_infill;
|
region_id = region_some_infill;
|
||||||
const LayerRegion& layerm = *layer.regions()[region_id];
|
const LayerRegion& layerm = *layer.regions()[region_id];
|
||||||
for (SurfaceFill &surface_fill : surface_fills)
|
for (SurfaceFill &surface_fill : surface_fills)
|
||||||
if (surface_fill.surface.surface_type == stInternalSolid && std::abs(layerm.layer()->height - surface_fill.params.flow.height) < EPSILON) {
|
if (surface_fill.surface.surface_type == stInternalSolid && std::abs(layer.height - surface_fill.params.flow.height) < EPSILON) {
|
||||||
internal_solid_fill = &surface_fill;
|
internal_solid_fill = &surface_fill;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -273,10 +275,10 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
|
||||||
// calculate the actual flow we'll be using for this infill
|
// calculate the actual flow we'll be using for this infill
|
||||||
params.flow = layerm.region()->flow(
|
params.flow = layerm.region()->flow(
|
||||||
frSolidInfill,
|
frSolidInfill,
|
||||||
layerm.layer()->height, // extrusion height
|
layer.height, // extrusion height
|
||||||
false, // bridge flow?
|
false, // bridge flow?
|
||||||
layerm.layer()->id() == 0, // first layer?
|
layer.id() == 0, // first layer?
|
||||||
-1, // auto width
|
-1, // auto width
|
||||||
*layer.object()
|
*layer.object()
|
||||||
);
|
);
|
||||||
params.spacing = params.flow.spacing();
|
params.spacing = params.flow.spacing();
|
||||||
|
@ -294,15 +296,48 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
|
||||||
return surface_fills;
|
return surface_fills;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
||||||
|
void export_group_fills_to_svg(const char *path, const std::vector<SurfaceFill> &fills)
|
||||||
|
{
|
||||||
|
BoundingBox bbox;
|
||||||
|
for (const auto &fill : fills)
|
||||||
|
for (const auto &expoly : fill.expolygons)
|
||||||
|
bbox.merge(get_extents(expoly));
|
||||||
|
Point legend_size = export_surface_type_legend_to_svg_box_size();
|
||||||
|
Point legend_pos(bbox.min(0), bbox.max(1));
|
||||||
|
bbox.merge(Point(std::max(bbox.min(0) + legend_size(0), bbox.max(0)), bbox.max(1) + legend_size(1)));
|
||||||
|
|
||||||
|
SVG svg(path, bbox);
|
||||||
|
const float transparency = 0.5f;
|
||||||
|
for (const auto &fill : fills)
|
||||||
|
for (const auto &expoly : fill.expolygons)
|
||||||
|
svg.draw(expoly, surface_type_to_color_name(fill.surface.surface_type), transparency);
|
||||||
|
export_surface_type_legend_to_svg(svg, legend_pos);
|
||||||
|
svg.Close();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// friend to Layer
|
// friend to Layer
|
||||||
void Layer::make_fills()
|
void Layer::make_fills()
|
||||||
{
|
{
|
||||||
for (LayerRegion *layerm : m_regions)
|
for (LayerRegion *layerm : m_regions)
|
||||||
layerm->fills.clear();
|
layerm->fills.clear();
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
||||||
|
// this->export_region_fill_surfaces_to_svg_debug("10_fill-initial");
|
||||||
|
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */
|
||||||
|
|
||||||
std::vector<SurfaceFill> surface_fills = group_fills(*this);
|
std::vector<SurfaceFill> surface_fills = group_fills(*this);
|
||||||
const Slic3r::BoundingBox bbox = this->object()->bounding_box();
|
const Slic3r::BoundingBox bbox = this->object()->bounding_box();
|
||||||
|
|
||||||
|
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
||||||
|
{
|
||||||
|
static int iRun = 0;
|
||||||
|
export_group_fills_to_svg(debug_out_path("Layer-fill_surfaces-10_fill-final-%d.svg", iRun ++).c_str(), surface_fills);
|
||||||
|
}
|
||||||
|
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */
|
||||||
|
|
||||||
for (SurfaceFill &surface_fill : surface_fills) {
|
for (SurfaceFill &surface_fill : surface_fills) {
|
||||||
// Create the filler object.
|
// Create the filler object.
|
||||||
std::unique_ptr<Fill> f = std::unique_ptr<Fill>(Fill::new_from_type(surface_fill.params.pattern));
|
std::unique_ptr<Fill> f = std::unique_ptr<Fill>(Fill::new_from_type(surface_fill.params.pattern));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue