ENH: add grid & rectilinear_interlaced interface pattern

Github: #1018, #1221
Jira: STUDIO-2534

Change-Id: I8c766b5b934364253c0344e39f474e4ac3b81add
(cherry picked from commit e7d46fe60856ab511905b46799943bfde8a71826)
This commit is contained in:
Arthur 2023-03-20 18:36:56 +08:00 committed by Lane.Wei
parent 9309831d26
commit af0fca211b
6 changed files with 51 additions and 18 deletions

View File

@ -1636,11 +1636,13 @@ void Fill::connect_infill(Polylines &&infill_ordered, const std::vector<const Po
double arc_length;
};
std::vector<Arc> arches;
arches.reserve(graph.map_infill_end_point_to_boundary.size());
for (ContourIntersectionPoint &cp : graph.map_infill_end_point_to_boundary)
if (cp.contour_idx != boundary_idx_unconnected && cp.next_on_contour != &cp && cp.could_connect_next())
arches.push_back({ &cp, path_length_along_contour_ccw(&cp, cp.next_on_contour, graph.boundary_params[cp.contour_idx].back()) });
std::sort(arches.begin(), arches.end(), [](const auto &l, const auto &r) { return l.arc_length < r.arc_length; });
if (!params.dont_sort) {
arches.reserve(graph.map_infill_end_point_to_boundary.size());
for (ContourIntersectionPoint& cp : graph.map_infill_end_point_to_boundary)
if (cp.contour_idx != boundary_idx_unconnected && cp.next_on_contour != &cp && cp.could_connect_next())
arches.push_back({ &cp, path_length_along_contour_ccw(&cp, cp.next_on_contour, graph.boundary_params[cp.contour_idx].back()) });
std::sort(arches.begin(), arches.end(), [](const auto& l, const auto& r) { return l.arc_length < r.arc_length; });
}
//FIXME improve the Traveling Salesman problem with 2-opt and 3-opt local optimization.
for (Arc &arc : arches)

View File

@ -76,6 +76,7 @@ struct FillParams
bool using_internal_flow{ false };
//BBS: only used for new top surface pattern
float no_extrusion_overlap{ 0.0 };
bool dont_sort{ false }; // do not sort the lines, just simply connect them
};
static_assert(IsTriviallyCopyable<FillParams>::value, "FillParams class is not POD (and it should be - see constructor).");

View File

@ -190,7 +190,9 @@ CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(SupportMaterialStyle)
static t_config_enum_values s_keys_map_SupportMaterialInterfacePattern {
{ "auto", smipAuto },
{ "rectilinear", smipRectilinear },
{ "concentric", smipConcentric }
{ "concentric", smipConcentric },
{ "rectilinear_interlaced", smipRectilinearInterlaced},
{ "grid", smipGrid }
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(SupportMaterialInterfacePattern)
@ -2634,9 +2636,13 @@ void PrintConfigDef::init_fff_params()
def->enum_values.push_back("auto");
def->enum_values.push_back("rectilinear");
def->enum_values.push_back("concentric");
def->enum_values.push_back("rectilinear_interlaced");
def->enum_values.push_back("grid");
def->enum_labels.push_back(L("Default"));
def->enum_labels.push_back(L("Rectilinear"));
def->enum_labels.push_back(L("Concentric"));
def->enum_labels.push_back(L("Rectilinear Interlaced"));
def->enum_labels.push_back(L("Grid"));
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionEnum<SupportMaterialInterfacePattern>(smipRectilinear));

View File

@ -104,7 +104,7 @@ enum SupportMaterialStyle {
};
enum SupportMaterialInterfacePattern {
smipAuto, smipRectilinear, smipConcentric,
smipAuto, smipRectilinear, smipConcentric, smipRectilinearInterlaced, smipGrid
};
// BBS

View File

@ -412,7 +412,12 @@ PrintObjectSupportMaterial::PrintObjectSupportMaterial(const PrintObject *object
support_pattern == smpHoneycomb ? ipHoneycomb :
m_support_params.support_density > 0.95 || m_support_params.with_sheath ? ipRectilinear : ipSupportBase;
m_support_params.interface_fill_pattern = (m_support_params.interface_density > 0.95 ? ipRectilinear : ipSupportBase);
m_support_params.contact_fill_pattern =
if (m_object_config->support_interface_pattern == smipGrid)
m_support_params.contact_fill_pattern = ipGrid;
else if (m_object_config->support_interface_pattern == smipRectilinearInterlaced)
m_support_params.contact_fill_pattern = ipRectilinear;
else
m_support_params.contact_fill_pattern =
(m_object_config->support_interface_pattern == smipAuto && m_slicing_params.soluble_interface) ||
m_object_config->support_interface_pattern == smipConcentric ?
ipConcentric :
@ -3642,7 +3647,6 @@ static inline void fill_expolygon_generate_paths(
ExPolygon &&expolygon,
Fill *filler,
const FillParams &fill_params,
float density,
ExtrusionRole role,
const Flow &flow)
{
@ -3664,12 +3668,11 @@ static inline void fill_expolygons_generate_paths(
ExPolygons &&expolygons,
Fill *filler,
const FillParams &fill_params,
float density,
ExtrusionRole role,
const Flow &flow)
{
for (ExPolygon &expoly : expolygons)
fill_expolygon_generate_paths(dst, std::move(expoly), filler, fill_params, density, role, flow);
fill_expolygon_generate_paths(dst, std::move(expoly), filler, fill_params, role, flow);
}
static inline void fill_expolygons_generate_paths(
@ -3683,7 +3686,7 @@ static inline void fill_expolygons_generate_paths(
FillParams fill_params;
fill_params.density = density;
fill_params.dont_adjust = true;
fill_expolygons_generate_paths(dst, std::move(expolygons), filler, fill_params, density, role, flow);
fill_expolygons_generate_paths(dst, std::move(expolygons), filler, fill_params, role, flow);
}
static inline void fill_expolygons_with_sheath_generate_paths(
@ -3731,7 +3734,7 @@ static inline void fill_expolygons_with_sheath_generate_paths(
}
extrusion_entities_append_paths(out, polylines, erSupportMaterial, flow.mm3_per_mm(), flow.width(), flow.height());
// Fill in the rest.
fill_expolygons_generate_paths(out, offset_ex(expoly, float(-0.4 * spacing)), filler, fill_params, density, role, flow);
fill_expolygons_generate_paths(out, offset_ex(expoly, float(-0.4 * spacing)), filler, fill_params, role, flow);
if (no_sort && ! eec->empty())
dst.emplace_back(eec.release());
}
@ -4581,13 +4584,23 @@ void PrintObjectSupportMaterial::generate_toolpaths(
double density = interface_as_base ? m_support_params.support_density : m_support_params.interface_density;
filler_interface->spacing = interface_as_base ? m_support_params.support_material_flow.spacing() : m_support_params.support_material_interface_flow.spacing();
filler_interface->link_max_length = coord_t(scale_(filler_interface->spacing * link_max_length_factor / density));
// BBS support more interface patterns
FillParams fill_params;
fill_params.density = density;
fill_params.dont_adjust = true;
if (m_object_config->support_interface_pattern == smipGrid) {
filler_interface->angle = Geometry::deg2rad(m_support_params.base_angle);
fill_params.dont_sort = true;
}
if (m_object_config->support_interface_pattern == smipRectilinearInterlaced)
filler_interface->layer_id = support_layer.interface_id();
fill_expolygons_generate_paths(
// Destination
layer_ex.extrusions,
// Regions to fill
union_safety_offset_ex(layer_ex.polygons_to_extrude()),
// Filler and its parameters
filler_interface.get(), float(density),
filler_interface.get(), fill_params,
// Extrusion parameters
erSupportMaterialInterface, interface_flow);
}

View File

@ -698,10 +698,15 @@ TreeSupport::TreeSupport(PrintObject& object, const SlicingParameters &slicing_p
ipSupportBase;
m_support_params.interface_fill_pattern = (m_support_params.interface_density > 0.95 ? ipRectilinear : ipSupportBase);
m_support_params.contact_fill_pattern = (m_object_config->support_interface_pattern == smipAuto && m_slicing_params.soluble_interface) ||
m_object_config->support_interface_pattern == smipConcentric ?
ipConcentric :
(m_support_params.interface_density > 0.95 ? ipRectilinear : ipSupportBase);
if (m_object_config->support_interface_pattern == smipGrid)
m_support_params.contact_fill_pattern = ipGrid;
else if (m_object_config->support_interface_pattern == smipRectilinearInterlaced)
m_support_params.contact_fill_pattern = ipRectilinear;
else
m_support_params.contact_fill_pattern = (m_object_config->support_interface_pattern == smipAuto && m_slicing_params.soluble_interface) ||
m_object_config->support_interface_pattern == smipConcentric ?
ipConcentric :
(m_support_params.interface_density > 0.95 ? ipRectilinear : ipSupportBase);
m_support_params.support_extrusion_width = m_object_config->support_line_width.value > 0 ? m_object_config->support_line_width : m_object_config->line_width;
is_slim = is_tree_slim(support_type, support_style);
MAX_BRANCH_RADIUS = 10.0;
@ -1573,6 +1578,12 @@ void TreeSupport::generate_toolpaths()
// roof_areas
fill_params.density = interface_density;
filler_interface->spacing = m_support_material_interface_flow.spacing();
if (m_object_config->support_interface_pattern == smipGrid) {
filler_interface->angle = Geometry::deg2rad(object_config.support_angle.value);
fill_params.dont_sort = true;
}
if (m_object_config->support_interface_pattern == smipRectilinearInterlaced)
filler_interface->layer_id = round(area_group.dist_to_top / ts_layer->height);
fill_expolygons_generate_paths(ts_layer->support_fills.entities, std::move(polys), filler_interface.get(), fill_params, erSupportMaterialInterface,
m_support_material_interface_flow);
}