Fully refactor SquashedConfig and ConfigView implementation

Make it so all the values are pre-resolved before backend code runs.
This includes:
- spread values if MMU is used
- expand parameters (first_layer_speed, extruder)
- ensure slot parity (extruder_offset)
- resolve overrides
- resolve FloatOrPercentages to floats
- resolve compatibility rules
This commit is contained in:
Martin Šach 2026-08-06 12:49:29 +02:00 • committed by Martin Šach
parent 2801dc2ed4
commit 5af3586ba2
85 changed files with 7995 additions and 7382 deletions

View file

@ -133,7 +133,7 @@ PenaltyBreakScopeResolution: 500
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyIndentedWhitespace: 400
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
QualifierAlignment: Leave

View file

@ -90,7 +90,7 @@ using Instances = std::vector<Object>;
struct SLAResultData
{
SerializedConfig serialized_config;
Domain::FullConfigSLA full_config;
Domain::ConfigView config;
std::optional<Domain::SLA::PrintStatistics> print_statistics;
Sla::OutputFiles files; // count files == slices.size()
Domain::Images thumbnails;

View file

@ -43,7 +43,8 @@ WallToolPaths::WallToolPaths(
const size_t inset_count,
const coord_t wall_0_inset,
const double layer_height,
const PrintRegionConfigView& print_region_config
const PrintRegionConfigView& print_region_config,
unsigned extruder_id
)
: outline(outline)
, bead_width_0(bead_width_0)
@ -59,21 +60,33 @@ WallToolPaths::WallToolPaths(
, wall_transition_length(0)
, toolpaths_generated(false)
, print_region_config(print_region_config)
, extruder_id(extruder_id)
{
ASSERT(extruder_id < std::numeric_limits<unsigned>::max());
const auto nozzle_diameters{Biz::Slicing::get_nozzle_diameters(print_region_config.hw_config())};
assert(!nozzle_diameters.empty());
this->min_nozzle_diameter = float(*std::min_element(nozzle_diameters.begin(), nozzle_diameters.end()));
const auto &min_feature_size_opt = print_region_config.get<Domain::FloatOrPercentage>("min_feature_size");
const auto min_feature_size_opt =
print_region_config.get<std::vector<Domain::FloatOrPercentage>>("min_feature_size")
.at(extruder_id);
this->min_feature_size = scaled<coord_t>(min_feature_size_opt.get_abs_value(this->min_nozzle_diameter));
const auto &min_bead_width_opt = print_region_config.get<Domain::FloatOrPercentage>("min_bead_width");
const auto min_bead_width_opt =
print_region_config.get<std::vector<Domain::FloatOrPercentage>>("min_bead_width")
.at(extruder_id);
this->min_bead_width = scaled<coord_t>(min_bead_width_opt.get_abs_value(this->min_nozzle_diameter));
const auto &wall_transition_filter_deviation_opt = print_region_config.get<Domain::FloatOrPercentage>("wall_transition_filter_deviation");
this->wall_transition_filter_deviation = scaled<coord_t>(wall_transition_filter_deviation_opt.get_abs_value(this->min_nozzle_diameter));
const auto wall_transition_filter_deviation_opt =
print_region_config
.get<std::vector<Domain::FloatOrPercentage>>("wall_transition_filter_deviation")
.at(extruder_id);
this->wall_transition_filter_deviation = scaled<coord_t>(
wall_transition_filter_deviation_opt.get_abs_value(this->min_nozzle_diameter));
const auto &wall_transition_length_opt = print_region_config.get<Domain::FloatOrPercentage>("wall_transition_length");
const auto wall_transition_length_opt =
print_region_config.get<std::vector<Domain::FloatOrPercentage>>("wall_transition_length")
.at(extruder_id);
this->wall_transition_length = scaled<coord_t>(wall_transition_length_opt.get_abs_value(this->min_nozzle_diameter));
}
@ -476,7 +489,9 @@ const std::vector<VariableWidthLines> &WallToolPaths::generate()
const coord_t smallest_segment = Slic3r::Arachne::meshfix_maximum_resolution;
const coord_t allowed_distance = Slic3r::Arachne::meshfix_maximum_deviation;
const coord_t epsilon_offset = (allowed_distance / 2) - 1;
const double transitioning_angle = deg2rad(this->print_region_config.get<double>("wall_transition_angle"));
const double transitioning_angle = deg2rad(
this->print_region_config.get<std::vector<double>>("wall_transition_angle")
.at(extruder_id));
constexpr coord_t discretization_step_size = scaled<coord_t>(0.8);
// Simplify outline for boost::voronoi consumption. Absolutely no self intersections or near-self intersections allowed:
@ -508,7 +523,7 @@ const std::vector<VariableWidthLines> &WallToolPaths::generate()
const double wall_split_middle_threshold = std::clamp(2. * unscaled<double>(this->min_bead_width) / external_perimeter_extrusion_width - 1., 0.01, 0.99); // For an uneven nr. of lines: When to split the middle wall into two.
const double wall_add_middle_threshold = std::clamp(unscaled<double>(this->min_bead_width) / perimeter_extrusion_width, 0.01, 0.99); // For an even nr. of lines: When to add a new middle in between the innermost two walls.
const int wall_distribution_count = this->print_region_config.get<int>("wall_distribution_count");
const int wall_distribution_count = this->print_region_config.get<std::vector<int>>("wall_distribution_count").at(extruder_id);
const size_t max_bead_count = (inset_count < std::numeric_limits<coord_t>::max() / 2) ? 2 * inset_count : std::numeric_limits<coord_t>::max();
const auto beading_strat = BeadingStrategyFactory::makeStrategy
(

View file

@ -48,7 +48,8 @@ public:
size_t inset_count,
coord_t wall_0_inset,
double layer_height,
const PrintRegionConfigView& print_region_config
const PrintRegionConfigView& print_region_config,
const unsigned extruder_id
);
/*!
@ -132,6 +133,7 @@ private:
std::vector<VariableWidthLines> toolpaths; //<! The generated toolpaths
Polygons inner_contour; //<! The inner contour of the generated toolpaths
PrintRegionConfigView print_region_config;
unsigned extruder_id;
};
} // namespace Slic3r::Arachne

View file

@ -1,5 +1,6 @@
#include "libslic3r/ConfigUtils.hpp"
#include <boost/algorithm/string/predicate.hpp>
#include "Slic3r/Domain/GCodeFlavor.hpp"
namespace Slic3r {
std::string get_extrusion_axis(const PrintConfigView& cfg)

View file

@ -34,15 +34,6 @@ public:
void add_override(const Domain::PartialVolumeConfigFDMPtr& override) {
m_partial_configs.push_back(override);
}
const Domain::PartialVolumeConfigFDM volume_settings() const {
return *std::dynamic_pointer_cast<const Domain::PartialVolumeConfigFDM>(m_partial_configs.back());
}
const Domain::Preset::HwPrinterConfig& hw_config() const
{
return std::dynamic_pointer_cast<const Domain::FullConfigFDM>(m_full_config)->hw_config();
}
};
class PrintObjectConfigView : public Domain::ConfigView
@ -52,17 +43,17 @@ public:
const Domain::FullConfigFDMPtr& full_config,
const Domain::PartialObjectConfigFDMPtr& object_settings
):
ConfigView{full_config, {object_settings}}
{}
const Domain::PartialObjectConfigFDMPtr object_settings() const {
return std::dynamic_pointer_cast<const Domain::PartialObjectConfigFDM>(m_partial_configs.front());
}
const Domain::Preset::HwPrinterConfig& hw_config() const
ConfigView{full_config, {object_settings}}, m_object_settings{object_settings}
{
return std::dynamic_pointer_cast<const Domain::FullConfigFDM>(m_full_config)->hw_config();
finalize();
}
const Domain::PartialObjectConfigFDMPtr& object_settings() const {
return m_object_settings;
}
private:
Domain::PartialObjectConfigFDMPtr m_object_settings;
};
class PrintConfigView : public Domain::ConfigView
@ -72,19 +63,14 @@ public:
const Domain::FullConfigFDMPtr& full_config
):
ConfigView{full_config, {}}
{}
{
finalize();
}
PrintConfigView():
ConfigView{std::make_shared<const Domain::FullConfigFDM>(Domain::FullConfigFDM::defaults()), {}}
{}
const Domain::FullConfigFDM& full_config() const {
return *std::dynamic_pointer_cast<const Domain::FullConfigFDM>(m_full_config);
}
const Domain::Preset::HwPrinterConfig& hw_config() const
{
return std::dynamic_pointer_cast<const Domain::FullConfigFDM>(m_full_config)->hw_config();
finalize();
}
};
@ -95,14 +81,14 @@ public:
const Domain::FullConfigSLAPtr& full_config
):
ConfigView{full_config, {}}
{}
{
finalize();
}
SLAPrintConfigView():
ConfigView{std::make_shared<const Domain::FullConfigSLA>(Domain::FullConfigSLA::defaults()), {}}
{}
const Domain::FullConfigSLA& full_config() const {
return *std::dynamic_pointer_cast<const Domain::FullConfigSLA>(m_full_config);
{
finalize();
}
};
@ -114,10 +100,8 @@ public:
const Domain::PartialObjectConfigSLAPtr& object_settings
):
ConfigView{full_config, {object_settings}}
{}
const Domain::PartialObjectConfigSLA& object_settings() const {
return *std::dynamic_pointer_cast<const Domain::PartialObjectConfigSLA>(m_partial_configs.front());
{
finalize();
}
};

View file

@ -75,12 +75,29 @@ ExtrudeConfig::ExtrudeConfig(const Domain::ConfigView& config) :
first_layer_infill_speed{
config.get<std::vector<Domain::FloatOrPercentage>>("first_layer_infill_speed")
},
first_layer_speed{config.get<std::vector<Domain::FloatOrPercentage>>("first_layer_speed")},
first_layer_solid_infill_speed{
config.get<std::vector<Domain::FloatOrPercentage>>("first_layer_solid_infill_speed")
},
first_layer_perimeter_speed{
config.get<std::vector<Domain::FloatOrPercentage>>("first_layer_perimeter_speed")
},
first_layer_external_perimeter_speed{
config.get<std::vector<Domain::FloatOrPercentage>>("first_layer_external_perimeter_speed")
},
first_layer_support_material_speed{
config.get<std::vector<Domain::FloatOrPercentage>>("first_layer_support_material_speed")
},
first_layer_top_solid_infill_speed{
config.get<std::vector<Domain::FloatOrPercentage>>("first_layer_top_solid_infill_speed")
},
first_layer_gap_fill_speed{
config.get<std::vector<Domain::FloatOrPercentage>>("first_layer_gap_fill_speed")
},
first_layer_speed_over_raft{
config.get<std::vector<Domain::FloatOrPercentage>>("first_layer_speed_over_raft")
},
avoid_crossing_perimeters_max_detour{
config.get<Domain::FloatOrPercentage>("avoid_crossing_perimeters_max_detour")
config.get<double>("avoid_crossing_perimeters_max_detour")
},
gcode_comments{config.get<bool>("gcode_comments")},
arc_fitting{config.get<Domain::ArcFittingType>("arc_fitting")},

View file

@ -1,7 +1,8 @@
#pragma once
#include "Slic3r/Domain/Config.hpp"
#include "Slic3r/Domain/ConfigBoxesFDM.hpp"
#include "Slic3r/Domain/ConfigDefsFDM.hpp"
#include "Slic3r/Domain/GCodeFlavor.hpp"
namespace Slic3r::Biz::Slicing {
struct ExtrudeConfig
@ -71,9 +72,14 @@ struct ExtrudeConfig
std::vector<Domain::FloatOrPercentage> over_bridge_speed{};
std::vector<Domain::FloatOrPercentage> top_solid_infill_speed{};
std::vector<Domain::FloatOrPercentage> first_layer_infill_speed{};
std::vector<Domain::FloatOrPercentage> first_layer_speed{};
std::vector<Domain::FloatOrPercentage> first_layer_solid_infill_speed{};
std::vector<Domain::FloatOrPercentage> first_layer_perimeter_speed{};
std::vector<Domain::FloatOrPercentage> first_layer_external_perimeter_speed{};
std::vector<Domain::FloatOrPercentage> first_layer_support_material_speed{};
std::vector<Domain::FloatOrPercentage> first_layer_top_solid_infill_speed{};
std::vector<Domain::FloatOrPercentage> first_layer_gap_fill_speed{};
std::vector<Domain::FloatOrPercentage> first_layer_speed_over_raft{};
Domain::FloatOrPercentage avoid_crossing_perimeters_max_detour{};
double avoid_crossing_perimeters_max_detour{};
bool gcode_comments{};
Domain::ArcFittingType arc_fitting{};
Domain::ScarfSeamPlacement scarf_seam_placement{};

View file

@ -1,4 +1,5 @@
#include "libslic3r/ExtruderCandidates.hpp"
#include "Slic3r/Domain/ConfigDefsFDM.hpp"
using Slic3r::Domain::TriangleSelector::TRIANGLE_STATE_TYPE_COUNT;
using Slic3r::Domain::TriangleSelector::TriangleStateType;

View file

@ -9,6 +9,7 @@
#include "FuzzySkin.hpp"
#include "libslic3r/ConfigViews.hpp"
#include "Slic3r/Domain/ConfigDefsFDM.hpp"
using namespace Slic3r;

View file

@ -551,6 +551,12 @@ void Layer::make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive:
params.use_arachne = (perimeter_generator == Domain::PerimeterGeneratorType::Arachne && surface_fill.params.pattern == Domain::InfillPattern::ipConcentric) || surface_fill.params.pattern == Domain::InfillPattern::ipEnsuring;
params.layer_height = layerm.layer()->height;
params.prefer_clockwise_movements = this->object()->print()->config().get<bool>("prefer_clockwise_movements");
FlowRole flow_role{
surface_fill.surface.is_top() ?
frTopSolidInfill :
(surface_fill.surface.is_solid() ? frSolidInfill : frInfill)};
ASSERT(layerm.region().extruder(flow_role) > 0);
params.extruder_id = layerm.region().extruder(flow_role) - 1;
for (ExPolygon &expoly : surface_fill.expolygons) {
// Spacing is modified by the filler to indicate adjustments. Reset it for each expolygon.
@ -739,6 +745,8 @@ Polylines Layer::generate_sparse_infill_polylines_for_anchoring(FillAdaptive::Oc
params.resolution = resolution;
params.use_arachne = false;
params.layer_height = layerm.layer()->height;
ASSERT(layerm.region().extruder(frInfill) > 0);
params.extruder_id = layerm.region().extruder(frInfill) - 1;
for (ExPolygon &expoly : surface_fill.expolygons) {
// Spacing is modified by the filler to indicate adjustments. Reset it for each expolygon.

View file

@ -24,6 +24,7 @@
#include "Slic3r/Domain/Point.hpp"
#include "Slic3r/Domain/Polyline.hpp"
#include "Slic3r/Domain/Types.hpp"
#include "Slic3r/Domain/ConfigDefsFDM.hpp"
#include "libslic3r/Fill/FillBase.hpp"

View file

@ -29,6 +29,7 @@
#include "Slic3r/Domain/Polyline.hpp"
#include "Slic3r/Domain/Types.hpp"
#include "Slic3r/Exception.hpp"
#include "Slic3r/Domain/ConfigDefsFDM.hpp"
#include "libslic3r/Utils.hpp"
#include "libslic3r/ConfigViews.hpp"
@ -86,6 +87,8 @@ struct FillParams
// For infills that produce closed loops to force printing those loops clockwise.
bool prefer_clockwise_movements { false };
unsigned extruder_id{std::numeric_limits<unsigned>::max()};
};
static_assert(std::is_trivially_copyable_v<FillParams>, "FillParams class is not POD (and it should be - see constructor).");

View file

@ -106,7 +106,7 @@ void FillConcentric::_fill_surface_single(const FillParams &params,
if (params.density > 0.9999f && !params.dont_adjust) {
coord_t loops_count = std::max(bbox_size.x(), bbox_size.y()) / min_spacing + 1;
Polygons polygons = offset(expolygon, float(min_spacing) / 2.f);
Arachne::WallToolPaths wallToolPaths(polygons, min_spacing, min_spacing, loops_count, 0, params.layer_height, this->region_config);
Arachne::WallToolPaths wallToolPaths(polygons, min_spacing, min_spacing, loops_count, 0, params.layer_height, this->region_config, params.extruder_id);
std::vector<Arachne::VariableWidthLines> loops = wallToolPaths.getToolPaths();
std::vector<const Arachne::ExtrusionLine *> all_extrusions;

View file

@ -467,7 +467,7 @@ ThickPolylines make_fill_polylines(
coord_t loops_count = (std::max(BB::sizes(ex_bb).x(), BB::sizes(ex_bb).y()) + scaled_spacing - 1) / scaled_spacing;
Polygons polygons = Algorithms::ExPolygon::to_polygons(ex_poly);
Arachne::WallToolPaths wall_tool_paths(polygons, scaled_spacing, scaled_spacing, loops_count, 0, params.layer_height,
fill->region_config);
fill->region_config, params.extruder_id);
if (std::vector<Arachne::VariableWidthLines> loops = wall_tool_paths.getToolPaths(); !loops.empty()) {
std::vector<const Arachne::ExtrusionLine *> all_extrusions;
for (Arachne::VariableWidthLines &loop : loops) {

View file

@ -160,7 +160,7 @@ static unsigned get_support_extruder_id(const PrintObject& object, bool is_inter
// If object->config().support_material_extruder == 0 (which means to not trigger tool change,
// but use the current extruder instead), use the smallest nozzle diameter.
const std::vector<double> nozzle_diameters{
Biz::Slicing::get_nozzle_diameters(object.config().hw_config())
object.config().get<std::vector<double>>("nozzle_diameter")
};
double min_nozzle_diameter{std::numeric_limits<double>::max()};
int min_nozzle_extruder_id{-1};

View file

@ -11,6 +11,7 @@
#include "Slic3r/Domain/Image.hpp"
#include "Slic3r/Biz/Algorithms/ImageUtils.hpp"
#include "Slic3r/Time.hpp"
#include "Slic3r/Domain/ConfigDefsSLA.hpp"
#include "Slic3r/Biz/Algorithms/MiniZWrapper.hpp" // IWYU pragma: keep
#include <LocalesUtils.hpp>

View file

@ -740,7 +740,7 @@ Biz::libpgcode::ProcessorResult GCodeGenerator::do_export(
ProcessorConfig processor_config = DoExport::populate_processor_config(
print->config(),
print->config().full_config().hw_config()
print->config().hw_config()
);
Processor processor(std::move(processor_config));
GCodeOutputStream file(processor);
@ -3604,11 +3604,25 @@ std::string GCodeGenerator::_extrude(
if (m_volumetric_speed.at(extruder_id) != 0. && speed == 0)
speed = m_volumetric_speed.at(extruder_id) / path_attr.mm3_per_mm;
if (this->on_first_layer()) {
const double first_layer_infill_speed{config.first_layer_infill_speed.at(extruder_id).get_abs_value(speed)};
if (path_attr.role == ExtrusionRole::SolidInfill && first_layer_infill_speed > 0) {
speed = first_layer_infill_speed;
if (path_attr.role == ExtrusionRole::InternalInfill) {
speed = config.first_layer_infill_speed.at(extruder_id).float_value();
} else if (path_attr.role == ExtrusionRole::SolidInfill) {
speed = config.first_layer_solid_infill_speed.at(extruder_id).float_value();
} else if (path_attr.role == ExtrusionRole::TopSolidInfill) {
speed = config.first_layer_top_solid_infill_speed.at(extruder_id).float_value();
} else if (path_attr.role == ExtrusionRole::Perimeter) {
speed = config.first_layer_perimeter_speed.at(extruder_id).float_value();
} else if (path_attr.role == ExtrusionRole::ExternalPerimeter) {
speed = config.first_layer_external_perimeter_speed.at(extruder_id).float_value();
} else if (path_attr.role == ExtrusionRole::SupportMaterial) {
speed = config.first_layer_support_material_speed.at(extruder_id).float_value();
} else if (path_attr.role == ExtrusionRole::GapFill) {
speed = config.first_layer_gap_fill_speed.at(extruder_id).float_value();
} else if (path_attr.role == ExtrusionRole::Skirt) {
speed = config.first_layer_support_material_speed.at(extruder_id).float_value();
} else {
speed = config.first_layer_speed.at(extruder_id).get_abs_value(speed);
SPDLOG_ERROR("Invalid speed on first layer, using first layer perimeter speed");
speed = config.first_layer_perimeter_speed.at(extruder_id).float_value();
}
}
else if (this->object_layer_over_raft())
@ -4081,7 +4095,7 @@ std::string GCodeGenerator::set_extruder(unsigned int extruder_id, double print_
if (pressure_advance != PressureAdvance::Disabled) {
gcode += m_writer.set_pressure_advance(
config.get<std::vector<double>>("pressure_advance_value").at(extruder_id),
this->m_print->config().full_config().hw_config().vendor_id
this->m_print->config().hw_config().vendor_id
);
if (pressure_advance == PressureAdvance::AutomaticCalibration) {
@ -4194,7 +4208,7 @@ std::string GCodeGenerator::set_extruder(unsigned int extruder_id, double print_
if (pressure_advance != PressureAdvance::Disabled) {
gcode += m_writer.set_pressure_advance(
config.get<std::vector<double>>("pressure_advance_value").at(extruder_id),
this->m_print->config().full_config().hw_config().vendor_id
this->m_print->config().hw_config().vendor_id
);
if (pressure_advance == PressureAdvance::AutomaticCalibration) {

View file

@ -1205,7 +1205,7 @@ static void init_boundary(AvoidCrossingPerimeters::Boundary *boundary, Polygons
Polyline AvoidCrossingPerimeters::travel_to(
const GCodeGenerator& gcodegen,
const Point& point,
const Domain::FloatOrPercentage& max_detour,
double max_detour,
const std::vector<double>& travel_max_lift,
bool* could_be_wipe_disabled
)
@ -1254,15 +1254,13 @@ Polyline AvoidCrossingPerimeters::travel_to(
travel_intersection_count = 0;
}
bool max_detour_length_exceeded = false;
if (!max_detour.is_zero()) {
bool max_detour_length_exceeded = false;
if (max_detour != 0) {
double direct_length = travel.length();
double detour = result_pl.length() - direct_length;
double max_detour_length = max_detour.is_percentage() ?
max_detour.get_abs_value(direct_length) :
scale_(max_detour.float_value());
double max_detour_length = scale_(max_detour);
if (detour > max_detour_length) {
result_pl = {start, end};
result_pl = {start, end};
max_detour_length_exceeded = true;
}
}

View file

@ -36,7 +36,7 @@ public:
Polyline travel_to(
const GCodeGenerator& gcodegen,
const Point& point,
const Domain::FloatOrPercentage &max_detour,
double max_detour,
const std::vector<double>& travel_max_lift
)
{
@ -47,7 +47,7 @@ public:
Polyline travel_to(
const GCodeGenerator& gcodegen,
const Point& point,
const Domain::FloatOrPercentage &max_detour,
double max_detour,
const std::vector<double>& travel_max_lift,
bool* could_be_wipe_disabled
);

View file

@ -1,6 +1,8 @@
#pragma once
#include "Slic3r/Domain/GCodeFlavor.hpp"
#include "libslic3r/ConfigViews.hpp"
#include "Slic3r/Domain/ConfigDefsFDM.hpp"
namespace Slic3r::Biz::Slicing {
struct CoolingBufferConfig

View file

@ -21,6 +21,7 @@
#include <iomanip>
#include "Slic3r/Domain/GCodeFlavor.hpp"
#include "Slic3r/Domain/ConfigDefsFDM.hpp"
#include "Slic3r/Domain/Types.hpp"
#include "libslic3r/libslic3r.h"

View file

@ -1,5 +1,6 @@
#include "libslic3r/GCode/GCodeWriterConfig.hpp"
#include "Slic3r/Domain/GCodeFlavor.hpp"
#include "Slic3r/Domain/ConfigDefsFDM.hpp"
namespace Slic3r::Biz::Slicing {

View file

@ -1,5 +1,6 @@
#pragma once
#include "Slic3r/Domain/GCodeFlavor.hpp"
#include "libslic3r/ConfigViews.hpp"
namespace Slic3r::Biz::Slicing {

View file

@ -635,8 +635,13 @@ WipeTower::WipeTower(
// it is taken over following default. Speeds from config are not
// easily accessible here.
const float default_speed = 60.f;
m_first_layer_speed = get_min_speed(
config.get<std::vector<Domain::FloatOrPercentage>>("first_layer_speed"),
m_first_layer_infill_speed = get_min_speed(
config.get<std::vector<Domain::FloatOrPercentage>>("first_layer_infill_speed"),
extruder_candidates,
default_speed
);
m_first_layer_perimeter_speed = get_min_speed(
config.get<std::vector<Domain::FloatOrPercentage>>("first_layer_perimeter_speed"),
extruder_candidates,
default_speed
);
@ -1237,7 +1242,7 @@ void WipeTower::toolchange_Wipe(
x_to_wipe = std::max(x_to_wipe, x_to_fill_cleaning_box);
}
const float target_speed = is_first_layer() ? m_first_layer_speed * 60.f : m_infill_speed * 60.f;
const float target_speed = is_first_layer() ? m_first_layer_infill_speed * 60.f : m_infill_speed * 60.f;
float wipe_speed = 0.33f * target_speed;
// if there is less than 2.5*line_width to the edge, advance straightaway (there is likely a blob anyway)
@ -1307,7 +1312,7 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
// Slow down on the 1st layer.
bool first_layer = is_first_layer();
float feedrate = first_layer ? m_first_layer_speed * 60.f : m_infill_speed * 60.f;
float feedrate = first_layer ? m_first_layer_infill_speed * 60.f : m_infill_speed * 60.f;
float current_depth = m_layer_info->depth - m_layer_info->toolchanges_depth();
box_coordinates fill_box(Vec2f(m_perimeter_width, m_layer_info->depth-(current_depth-m_perimeter_width)),
m_wipe_tower_width - 2 * m_perimeter_width, current_depth-m_perimeter_width);
@ -1489,7 +1494,7 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
return poly;
};
feedrate = first_layer ? m_first_layer_speed * 60.f : m_perimeter_speed * 60.f;
feedrate = first_layer ? m_first_layer_perimeter_speed * 60.f : m_perimeter_speed * 60.f;
// outer contour (always)
bool infill_cone = first_layer && m_wipe_tower_width > 2*spacing && m_wipe_tower_depth > 2*spacing;

View file

@ -293,7 +293,8 @@ private:
float m_travel_speed = 0.f;
float m_infill_speed = 0.f;
float m_perimeter_speed = 0.f;
float m_first_layer_speed = 0.f;
float m_first_layer_perimeter_speed = 0.f;
float m_first_layer_infill_speed = 0.f;
size_t m_first_layer_idx = size_t(-1);
// G-code generator parameters.

View file

@ -1054,7 +1054,7 @@ void PerimeterGenerator::process_arachne(
ExPolygons last = offset_ex(Algorithms::ExPolygon::simplify_to_polygons(surface.expolygon, params.scaled_resolution), - float(ext_perimeter_width / 2. - ext_perimeter_spacing / 2.));
Polygons last_p = Algorithms::ExPolygon::to_polygons(last);
Arachne::WallToolPaths wall_tool_paths(last_p, ext_perimeter_spacing, perimeter_spacing, coord_t(loop_number + 1), 0, params.layer_height, params.config);
Arachne::WallToolPaths wall_tool_paths(last_p, ext_perimeter_spacing, perimeter_spacing, coord_t(loop_number + 1), 0, params.layer_height, params.config, extruder_id);
Arachne::Perimeters perimeters = wall_tool_paths.getToolPaths();
ExPolygons infill_contour = union_ex(wall_tool_paths.getInnerContour());
@ -1097,7 +1097,7 @@ void PerimeterGenerator::process_arachne(
top_expolygons = intersection_ex(top_expolygons, infill_contour);
const Polygons not_top_polygons = Algorithms::ExPolygon::to_polygons(not_top_expolygons);
Arachne::WallToolPaths inner_wall_tool_paths(not_top_polygons, perimeter_spacing, perimeter_spacing, coord_t(inner_loop_number + 1), 0, params.layer_height, params.config);
Arachne::WallToolPaths inner_wall_tool_paths(not_top_polygons, perimeter_spacing, perimeter_spacing, coord_t(inner_loop_number + 1), 0, params.layer_height, params.config, extruder_id);
Arachne::Perimeters inner_perimeters = inner_wall_tool_paths.getToolPaths();
// Recalculate indexes of inner perimeters before merging them.
@ -1116,7 +1116,7 @@ void PerimeterGenerator::process_arachne(
} else {
// There is no top surface ExPolygon, so we call Arachne again with parameters
// like when the single perimeter feature is disabled.
Arachne::WallToolPaths no_single_perimeter_tool_paths(last_p, ext_perimeter_spacing, perimeter_spacing, coord_t(inner_loop_number + 2), 0, params.layer_height, params.config);
Arachne::WallToolPaths no_single_perimeter_tool_paths(last_p, ext_perimeter_spacing, perimeter_spacing, coord_t(inner_loop_number + 2), 0, params.layer_height, params.config, extruder_id);
perimeters = no_single_perimeter_tool_paths.getToolPaths();
infill_contour = union_ex(no_single_perimeter_tool_paths.getInnerContour());
}

View file

@ -31,6 +31,7 @@
#include "Slic3r/Biz/libpgcode/ProcessorResult.hpp"
#include "Slic3r/Domain/BoundingBox.hpp"
#include "Slic3r/Domain/ConfigCommon.hpp"
#include "Slic3r/Domain/ConfigPack.hpp"
#include "Slic3r/Domain/ModelObject.hpp"
#include "Slic3r/Domain/Point.hpp"
@ -50,6 +51,7 @@
#include "libslic3r/PrintSteps.hpp"
#include "libslic3r/Slicing.hpp"
#include "libslic3r/SupportSpotsGenerator.hpp"
#include "Slic3r/Domain/ConfigDefsFDM.hpp"
namespace Slic3r {
@ -113,6 +115,7 @@ public:
// Methods NOT modifying the PrintRegion's state:
public:
const PrintRegionConfigView& config() const throw() { return m_config; }
void finalize_config() { m_config.finalize(); };
size_t config_hash() const throw() { return m_config_hash; }
// Identifier of this PrintRegion in the list of Print::m_print_regions.
int print_region_id() const throw() { return m_print_region_id; }

View file

@ -172,16 +172,16 @@ public:
LayerRanges() = default;
LayerRanges(
const Domain::LayerConfigRanges& in,
const std::size_t material_slot_count
const Domain::Preset::HwPrinterConfig& hw_config
)
{
this->assign(in, material_slot_count);
this->assign(in, hw_config);
}
// Convert input config ranges into continuous non-overlapping sorted vector of intervals and their configs.
void assign(
const Domain::LayerConfigRanges& in,
const std::size_t material_slot_count
const Domain::Preset::HwPrinterConfig& hw_config
)
{
m_ranges.clear();
@ -196,7 +196,7 @@ public:
last_z = min_z;
}
if (range.first.second > last_z + EPSILON) {
const auto cfg{prepare_slicing_volume_input(range.second, material_slot_count)};
const auto cfg{prepare_slicing_volume_input(range.second, hw_config, hw_config.material_slot_count())};
m_ranges.push_back(
{Domain::LayerHeightRange(last_z, range.first.second), cfg.value()}
);
@ -498,7 +498,7 @@ PrintRegionConfigView create_mm_painted_region_config(
PrintRegionConfigView painted_region_cfg = parent_config;
const PartialVolumeConfigFDM squashed_volume_config{
volume_settings,
parent_config.hw_config().material_slot_count()
parent_config.hw_config()
};
painted_region_cfg.add_override(
std::make_shared<PartialVolumeConfigFDM>(squashed_volume_config)
@ -517,7 +517,7 @@ PrintRegionConfigView create_fuzzy_skin_painted_region_config(
PrintRegionConfigView painted_region_cfg = parent_config;
const PartialVolumeConfigFDM squashed_volume_config{
volume_settings,
parent_config.hw_config().material_slot_count()
parent_config.hw_config()
};
painted_region_cfg.add_override(
std::make_shared<PartialVolumeConfigFDM>(squashed_volume_config)
@ -583,6 +583,7 @@ generate_print_object_regions(
}
const auto squashed_settings{prepare_slicing_volume_input(
volume.volume_settings,
new_full_config->hw_config(),
new_full_config->hw_config().material_slot_count()
)};
if (!squashed_settings.has_value()) {
@ -619,6 +620,7 @@ generate_print_object_regions(
const auto squashed_settings{
prepare_slicing_volume_input(
volume.volume_settings,
new_full_config->hw_config(),
new_full_config->hw_config().material_slot_count()
)
};
@ -684,6 +686,10 @@ generate_print_object_regions(
}
}
for (std::unique_ptr<PrintRegion>& region : all_regions) {
region->finalize_config();
}
return out;
}
@ -1048,6 +1054,7 @@ tl::expected<PrintObjectsSyncResult, Errors> sync_print_objects(
const auto object_settings{prepare_slicing_object_input(
model_object->object_settings,
new_full_config->hw_config(),
new_full_config->hw_config().material_slot_count()
)};
if (!object_settings.has_value()) {
@ -1112,7 +1119,7 @@ tl::expected<RegionsSyncResult, Errors> sync_regions(
const auto new_regions{generate_print_object_regions(
nullptr,
print_object.model_object()->volumes,
LayerRanges(print_object.model_object()->layer_config_ranges, new_full_config->hw_config().material_slot_count()),
LayerRanges(print_object.model_object()->layer_config_ranges, new_full_config->hw_config()),
print_object.config().object_settings(),
new_full_config,
print_object.trafo(),
@ -1475,7 +1482,7 @@ Biz::Slicing::ApplyStatus::Status Print::apply(
m_config = new_print_config;
m_placeholder_parser = init_placeholder_parser(
Biz::Parser::IO::get_parser_config(*new_full_config_ptr),
Biz::Parser::IO::get_parser_config(new_print_config),
wipe_tower,
metadata
);

View file

@ -2886,7 +2886,7 @@ void PrintObject::combine_infill()
for (size_t region_id = 0; region_id < this->num_printing_regions(); ++region_id) {
const PrintRegion &region = this->printing_region(region_id);
const size_t combine_infill_every_n_layers = region.extruder_config_value<int>("infill_every_layers", FlowRole::frInfill);
const bool automatic_infill_combination = region.config().get<bool>("automatic_infill_combination");
const bool automatic_infill_combination = region.extruder_config_value<bool>("automatic_infill_combination", FlowRole::frInfill);
const bool enable_combine_infill = automatic_infill_combination || combine_infill_every_n_layers >= 2;
if (!enable_combine_infill || region.extruder_config_value<Domain::Percentage>("fill_density", FlowRole::frInfill) == Domain::Percentage{0.}) {
@ -2900,7 +2900,7 @@ void PrintObject::combine_infill()
region.nozzle_diameter(FlowRole::frSolidInfill)
);
const double automatic_infill_combination_max_layer_height = region.config().get<Domain::FloatOrPercentage>("automatic_infill_combination_max_layer_height").get_abs_value(nozzle_diameter);
const double automatic_infill_combination_max_layer_height = region.extruder_config_value<Domain::FloatOrPercentage>("automatic_infill_combination_max_layer_height", FlowRole::frInfill).get_abs_value(nozzle_diameter);
const double max_combine_layer_height = automatic_infill_combination ? std::min(automatic_infill_combination_max_layer_height, nozzle_diameter) : nozzle_diameter;
// define the combinations

View file

@ -13,6 +13,7 @@
#include "Slic3r/Domain/ExPolygon.hpp"
#include "Slic3r/Domain/ConfigBoxesSLA.hpp"
#include "Slic3r/Domain/ConfigDefsSLA.hpp"
#include "Slic3r/Domain/SLA/SupportPoint.hpp"
#include "Slic3r/Biz/Algorithms/AABBMesh.hpp"

View file

@ -706,7 +706,8 @@ PrintObjectsSyncResult sync_print_objects(
const auto it{reuse_candidates.find(model_object->id())};
const auto object_settings_ptr{std::make_shared<PartialObjectConfigSLA>(
model_object->object_settings_sla
model_object->object_settings_sla,
new_full_config->hw_config()
)};
const SLAPrintObjectConfigView new_config{
new_full_config,
@ -954,7 +955,7 @@ InvalidatedSteps SLAPrint::apply(
check_model_ids_validity(model);
#endif /* _DEBUG */
const auto new_full_config_ptr{std::make_shared<FullConfigSLA>(config_pack)};
const auto new_full_config_ptr{std::make_shared<FullConfigSLA>(config_pack, metadata.hw_config)};
const SLAPrintConfigView new_print_config{new_full_config_ptr};
m_metadata = metadata;
m_metadata_serializer = serializer;
@ -963,7 +964,7 @@ InvalidatedSteps SLAPrint::apply(
// Grab the lock for the Print / PrintObject milestones.
std::scoped_lock<std::mutex> lock(this->state_mutex());
m_placeholder_parser = PlaceholderParser{Biz::Parser::IO::get_parser_config(config_pack)};
m_placeholder_parser = PlaceholderParser{Biz::Parser::IO::get_parser_config(new_print_config)};
// It is also safe to change m_config now after this->invalidate_state_by_config_options() call.
m_print_config = new_print_config;

View file

@ -18,6 +18,9 @@
#include <vector>
#include <cassert>
#include "Slic3r/Domain/ConfigDefsSLA.hpp"
#include "Slic3r/Domain/ConfigCommon.hpp"
#include "Slic3r/Domain/SLA/SupportPoint.hpp"
#include "Slic3r/Exception.hpp"
#include "Slic3r/Biz/Algorithms/ExPolygon.hpp"
#include "Slic3r/Biz/Algorithms/Execution/Execution.hpp"
@ -1551,7 +1554,7 @@ void SLAPrint::Steps::merge_slices_and_eval_stats() {
m_print->m_on_sla_result(Biz::Slicing::SLAResult{
.export_data = std::make_shared<SLAResultData>(SLAResultData{
.serialized_config = m_print->build_serialized_config(print_statistics),
.full_config = config.full_config(),
.config = config,
.print_statistics = print_statistics,
}),
.slices = std::move(slices),
@ -1648,7 +1651,7 @@ void SLAPrint::Steps::rasterize()
// Send encoded files to frontend for export files for printer
m_print->m_on_sla_result(SLAResult{
.export_data = std::make_shared<SLAResultData>(SLAResultData{
.full_config = printer_config.full_config(),
.config = printer_config,
.files = OutputFiles{
.data = std::move(files),
.type = output_type

View file

@ -13,6 +13,7 @@
#include "libslic3r/HwConfigUtils.hpp"
#include "libslic3r/ShrinkageCompensation.hpp"
#include "libslic3r/SlicingInput.hpp"
#include "Slic3r/Domain/ConfigDefsFDM.hpp"
#include <limits>
#include <algorithm>
@ -177,6 +178,7 @@ SlicingParameters SlicingParameters::create_from_config(
const auto partial_object_config_fdm = prepare_slicing_object_input(
object_settings,
hw_config,
hw_config.material_slot_count()
);
ASSERT(partial_object_config_fdm.has_value());

View file

@ -90,20 +90,22 @@ tl::expected<FullConfigFDMPtr, std::vector<Error>> prepare_slicing_input(
tl::expected<PartialObjectConfigFDMPtr, std::vector<Error>> prepare_slicing_object_input(
const ObjectSettings& object_settings,
const Domain::Preset::HwPrinterConfig& hw_config,
const std::size_t material_slot_count
)
{
PartialObjectConfigFDM result{object_settings, material_slot_count};
PartialObjectConfigFDM result{object_settings, hw_config};
set_extruders(result, object_settings, material_slot_count);
return std::make_shared<PartialObjectConfigFDM>(std::move(result));
};
tl::expected<PartialVolumeConfigFDMPtr, std::vector<Error>> prepare_slicing_volume_input(
const VolumeSettings& volume_settings,
const Domain::Preset::HwPrinterConfig& hw_config,
const std::size_t material_slot_count
)
{
PartialVolumeConfigFDM result{volume_settings, material_slot_count};
PartialVolumeConfigFDM result{volume_settings, hw_config};
set_extruders(result, volume_settings, material_slot_count);
return std::make_shared<const PartialVolumeConfigFDM>(std::move(result));
}

View file

@ -17,12 +17,14 @@ prepare_slicing_input(
[[nodiscard]] tl::expected<Domain::PartialObjectConfigFDMPtr, std::vector<Biz::Slicing::Error>>
prepare_slicing_object_input(
const Domain::ObjectSettings& object_settings,
const Domain::Preset::HwPrinterConfig& hw_config,
const std::size_t material_slot_count
);
[[nodiscard]] tl::expected<Domain::PartialVolumeConfigFDMPtr, std::vector<Biz::Slicing::Error>>
prepare_slicing_volume_input(
const Domain::VolumeSettings& volume_settings,
const Domain::Preset::HwPrinterConfig& hw_config,
const std::size_t material_slot_count
);
} // namespace Slic3r

View file

@ -268,8 +268,13 @@ const std::map<std::string, std::vector<Step>> invalidated_by{
propagate(psSkirtBrim)}
)},
{"first_layer_height", steps({propagate(posSlice)})},
{"first_layer_infill_speed", steps({propagate(psGCodeExport)})},
{"first_layer_speed", steps({propagate(psWipeTower), propagate(psSkirtBrim)})},
{"first_layer_infill_speed", steps({propagate(psWipeTower), propagate(psSkirtBrim)})},
{"first_layer_solid_infill_speed", steps({propagate(psWipeTower), propagate(psSkirtBrim)})},
{"first_layer_perimeter_speed", steps({propagate(psWipeTower), propagate(psSkirtBrim)})},
{"first_layer_external_perimeter_speed", steps({propagate(psWipeTower), propagate(psSkirtBrim)})},
{"first_layer_support_material_speed", steps({propagate(psWipeTower), propagate(psSkirtBrim)})},
{"first_layer_top_solid_infill_speed", steps({propagate(psWipeTower), propagate(psSkirtBrim)})},
{"first_layer_gap_fill_speed", steps({propagate(psWipeTower), propagate(psSkirtBrim)})},
{"first_layer_speed_over_raft", steps({propagate(psGCodeExport)})},
{"first_layer_temperature", steps({propagate(psWipeTower), propagate(psSkirtBrim)})},
{"full_fan_speed_layer", steps({propagate(psGCodeExport)})},

View file

@ -44,20 +44,15 @@ TreeSupportMeshGroupSettings::TreeSupportMeshGroupSettings(const PrintObject &pr
this->resolution = scaled<coord_t>(print_config.get<double>("gcode_resolution"));
// Arache feature
const auto min_feature_size{config.get<Domain::FloatOrPercentage>("min_feature_size")};
if (min_feature_size.is_percentage()) {
const auto nozzle_diameters{Biz::Slicing::get_nozzle_diameters(config.hw_config())};
const double max_nozzle_diameter{std::accumulate(
nozzle_diameters.begin(),
nozzle_diameters.end(),
0.0,
[](double a, double b) { return std::max(a, b); }
)};
ASSERT(max_nozzle_diameter > 0.0);
this->min_feature_size = scaled<coord_t>(min_feature_size.get_abs_value(max_nozzle_diameter));
} else {
this->min_feature_size = scaled<coord_t>(min_feature_size.float_value());
const auto min_feature_sizes{config.get<std::vector<Domain::FloatOrPercentage>>("min_feature_size")};
double min_feature_size{min_feature_sizes.empty() ? 0 : std::numeric_limits<double>::max()};
for (const Domain::FloatOrPercentage& size : min_feature_sizes) {
ASSERT(!size.is_percentage());
if (size.float_value() < min_feature_size) {
min_feature_size = size.float_value();
}
}
this->min_feature_size = scaled<coord_t>(min_feature_size);
// +1 makes the threshold inclusive
this->support_angle = 0.5 * M_PI - std::clamp<double>((config.get<int>("support_material_threshold") + 1) * M_PI / 180., 0., 0.5 * M_PI);
this->support_line_width = support_material_flow(&print_object, config.get<double>("layer_height")).scaled_width();

View file

@ -14,6 +14,7 @@
#include <utility>
#include "Slic3r/Domain/ConfigBoxesFDM.hpp"
#include "Slic3r/Domain/ConfigDefsFDM.hpp"
#include "Slic3r/Domain/ExPolygon.hpp"
#include "Slic3r/Domain/Line.hpp"
#include "Slic3r/Domain/Polygon.hpp"

View file

@ -39,47 +39,24 @@ TEST_CASE("CLI slices a single-tool 3MF project", "[cli][timeout]")
const fs::path exported_3mf_path = temp_dir.path() / "cube.3mf";
const fs::path gcode_path = temp_dir.path() / "print.gcode";
App::InitParams export_params = make_single_tool_params();
export_params.input.input_files.push_back(cube_stl_path.string());
export_params.action.export_3mf = true;
export_params.misc.output = exported_3mf_path.string();
for (const TestProfileSet& profile_set : resolved_profile_sets()) {
App::InitParams export_params = make_params(profile_set);
export_params.input.input_files.push_back(cube_stl_path.string());
export_params.action.export_3mf = true;
export_params.misc.output = exported_3mf_path.string();
REQUIRE(App::CLI::run(export_params) == EXIT_SUCCESS);
REQUIRE(fs::exists(exported_3mf_path));
REQUIRE(App::CLI::run(export_params) == EXIT_SUCCESS);
REQUIRE(fs::exists(exported_3mf_path));
App::InitParams slice_params;
slice_params.input.input_files.push_back(exported_3mf_path.string());
slice_params.action.export_gcode = true;
slice_params.misc.output = gcode_path.string();
App::InitParams slice_params;
slice_params.input.input_files.push_back(exported_3mf_path.string());
slice_params.action.export_gcode = true;
slice_params.misc.output = gcode_path.string();
REQUIRE(App::CLI::run(slice_params) == EXIT_SUCCESS);
REQUIRE(fs::exists(gcode_path));
REQUIRE(fs::file_size(gcode_path) > 0);
}
TEST_CASE("CLI slices a multi-tool 3MF project", "[cli][timeout]")
{
const ScopedTempDir temp_dir;
const fs::path cube_stl_path = write_cube_stl(temp_dir.path(), "cube.stl", 20.);
const fs::path exported_3mf_path = temp_dir.path() / "cube.3mf";
const fs::path gcode_path = temp_dir.path() / "print.gcode";
App::InitParams export_params = make_multi_tool_params();
export_params.input.input_files.push_back(cube_stl_path.string());
export_params.action.export_3mf = true;
export_params.misc.output = exported_3mf_path.string();
REQUIRE(App::CLI::run(export_params) == EXIT_SUCCESS);
REQUIRE(fs::exists(exported_3mf_path));
App::InitParams slice_params;
slice_params.input.input_files.push_back(exported_3mf_path.string());
slice_params.action.export_gcode = true;
slice_params.misc.output = gcode_path.string();
REQUIRE(App::CLI::run(slice_params) == EXIT_SUCCESS);
REQUIRE(fs::exists(gcode_path));
REQUIRE(fs::file_size(gcode_path) > 0);
REQUIRE(App::CLI::run(slice_params) == EXIT_SUCCESS);
REQUIRE(fs::exists(gcode_path));
REQUIRE(fs::file_size(gcode_path) > 0);
}
}
TEST_CASE("CLI slices multiple STL inputs into separate G-codes", "[cli][timeout]")
@ -88,7 +65,7 @@ TEST_CASE("CLI slices multiple STL inputs into separate G-codes", "[cli][timeout
const fs::path first_cube_stl_path = write_cube_stl(temp_dir.path(), "cube_a.stl", 20.);
const fs::path second_cube_stl_path = write_cube_stl(temp_dir.path(), "cube_b.stl", 20.);
App::InitParams slice_params = make_single_tool_params();
App::InitParams slice_params = make_params(resolved_profile_sets().front());
slice_params.input.input_files.push_back(first_cube_stl_path.string());
slice_params.input.input_files.push_back(second_cube_stl_path.string());
slice_params.action.export_gcode = true;
@ -104,7 +81,7 @@ TEST_CASE("CLI reports objects scaled outside the print volume instead of freezi
const fs::path cube_stl_path = write_cube_stl(temp_dir.path(), "cube.stl", 20.);
const fs::path gcode_path = temp_dir.path() / "huge.gcode";
App::InitParams slice_params = make_single_tool_params();
App::InitParams slice_params = make_params(resolved_profile_sets().front());
slice_params.input.input_files.push_back(cube_stl_path.string());
slice_params.transform.scale = FloatOrPercentage{100.0};
slice_params.action.export_gcode = true;
@ -125,7 +102,7 @@ TEST_CASE("CLI centers a loaded STL on the bed", "[cli][timeout]")
const auto export_and_load = [&](const bool dont_arrange)
{
InitParams export_params = make_single_tool_params();
App::InitParams export_params = make_params(resolved_profile_sets().front());
export_params.input.input_files.push_back(cube_stl_path.string());
export_params.transform.dont_arrange = dont_arrange;
export_params.action.export_3mf = true;

View file

@ -31,8 +31,10 @@ namespace Slic3r::App::CLI::Test {
namespace {
TestProfileSet pick_profile_set(const Bundle& preset_bundle, const bool multi_tool)
std::vector<TestProfileSet> get_test_printer_profile_sets(const Bundle& preset_bundle)
{
std::vector<TestProfileSet> result;
for (const std::vector<EvaluatedPrinterPreset>& printer_presets :
preset_bundle.evaluated_presets | std::views::values)
{
@ -42,9 +44,6 @@ TestProfileSet pick_profile_set(const Bundle& preset_bundle, const bool multi_to
}
const std::size_t tool_count = printer_preset.hw_config.tool_count;
if (multi_tool ? tool_count < 2 : tool_count != 1) {
continue;
}
if (printer_preset.prints.empty()) {
continue;
@ -76,24 +75,25 @@ TestProfileSet pick_profile_set(const Bundle& preset_bundle, const bool multi_to
}
}
return TestProfileSet{
.printer_profile_name = printer_preset.hw_config.name,
.print_profile_name = chosen_print_preset->preset.name,
.material_profile_name = chosen_material_preset->preset.name,
.tool_count = tool_count
};
result.push_back(
TestProfileSet{.printer_profile_name = printer_preset.hw_config.name,
.print_profile_name = chosen_print_preset->preset.name,
.material_profile_name = chosen_material_preset->preset.name,
.tool_count = tool_count});
}
}
throw std::runtime_error(
multi_tool ? "No suitable multi-tool FFF printer was found in the preset bundle." :
"No suitable single-tool FFF printer was found in the preset bundle."
);
if (result.empty()) {
throw std::runtime_error{"No suitable printers were found in the preset bundle."};
}
return result;
}
const std::pair<TestProfileSet, TestProfileSet>& resolved_profile_sets()
} // namespace
const std::vector<TestProfileSet>& resolved_profile_sets()
{
static const std::pair<TestProfileSet, TestProfileSet> profile_sets = []()
static const std::vector<TestProfileSet> profile_sets = []()
{
Workbench workbench;
SceneInteractor scene_interactor{workbench};
@ -101,27 +101,12 @@ const std::pair<TestProfileSet, TestProfileSet>& resolved_profile_sets()
preset_interactor.load_preset_bundle(Preset::IO::BundlePaths::make_standard_runtime());
const Bundle& preset_bundle = workbench.preset_bundle();
return std::make_pair(
pick_profile_set(preset_bundle, false),
pick_profile_set(preset_bundle, true)
);
return get_test_printer_profile_sets(preset_bundle);
}();
return profile_sets;
}
} // namespace
const TestProfileSet& single_tool_profile_set()
{
return resolved_profile_sets().first;
}
const TestProfileSet& multi_tool_profile_set()
{
return resolved_profile_sets().second;
}
ScopedTempDir::ScopedTempDir() :
m_path(
boost::filesystem::temp_directory_path()
@ -150,21 +135,8 @@ boost::filesystem::path write_cube_stl(
return stl_path;
}
InitParams make_single_tool_params()
InitParams make_params(const TestProfileSet& profile_set)
{
const TestProfileSet& profile_set = single_tool_profile_set();
InitParams init_params;
init_params.input.printer_profile_preset = profile_set.printer_profile_name;
init_params.input.print_profile_preset = profile_set.print_profile_name;
init_params.input.material_profile_presets.emplace_back(profile_set.material_profile_name);
return init_params;
}
InitParams make_multi_tool_params()
{
const TestProfileSet& profile_set = multi_tool_profile_set();
InitParams init_params;
init_params.input.printer_profile_preset = profile_set.printer_profile_name;
init_params.input.print_profile_preset = profile_set.print_profile_name;

View file

@ -20,15 +20,7 @@ struct TestProfileSet
std::size_t tool_count{0};
};
/**
* @brief A single-tool printer with a compatible print and material profile.
*/
const TestProfileSet& single_tool_profile_set();
/**
* @brief A multi-tool (tool_count >= 2) printer with a compatible print and material profile.
*/
const TestProfileSet& multi_tool_profile_set();
const std::vector<TestProfileSet>& resolved_profile_sets();
/**
* @brief Unique temporary directory removed at the end of the scope.
@ -62,15 +54,7 @@ boost::filesystem::path write_cube_stl(
double cube_size_mm
);
/**
* @brief InitParams with the full single-tool profile set filled in.
*/
InitParams make_single_tool_params();
/**
* @brief InitParams with the full multi-tool profile set filled in.
*/
InitParams make_multi_tool_params();
InitParams make_params(const TestProfileSet& profile_set);
/**
* @brief Counts the regular files with a .gcode or .bgcode extension in the directory.

View file

@ -32,8 +32,6 @@ enum class Type
Strings,
Percent,
Percents,
FloatOrPercent,
FloatsOrPercents,
Point,
Points,
Bool,
@ -46,7 +44,7 @@ struct Scalar
{
template<typename T>
requires (!std::is_enum_v<T>)
explicit Scalar(const T& value, const std::string& ratio_over = "");
explicit Scalar(const T& value);
template<typename T>
requires std::is_enum_v<T> explicit Scalar(const T& value, const std::string& serialized_value)
@ -59,10 +57,8 @@ struct Scalar
Type type() const;
std::string serialize() const;
std::string ratio_over() const;
bool is_optional() const;
bool is_nil() const;
template<typename T>
requires (!std::is_enum_v<T>)
@ -78,7 +74,6 @@ struct Scalar
}
private:
std::string m_ratio_over;
std::any m_value;
Type m_type{Type::None};
@ -169,7 +164,6 @@ private:
std::vector<std::string> keys() const;
};
Config get_parser_config(const Domain::FullConfigFDM& config_pack);
Config get_parser_config(const Domain::FullConfigSLA& config_pack);
Config get_parser_config(const Domain::ConfigView& config_view);
} // namespace Slic3r::Parser::IO

View file

@ -11,18 +11,12 @@
namespace Slic3r::Biz::Parser::IO {
using Domain::Percentage;
using Domain::FloatOrPercentage;
using Domain::Vec2d;
using Domain::FullConfig;
using Domain::FullConfigFDM;
using Domain::FullConfigSLA;
using Domain::ConfigPackFDM;
using Domain::ConfigPackSLA;
using Domain::ConfigView;
using Domain::ConfigPack;
using Domain::EnumWrapper;
using Domain::EnumVectorWrapper;
using Domain::ConfigValue;
using Domain::overloaded;
// clang-format off
template<typename T>
@ -43,8 +37,6 @@ template<> struct get_option_type<std::string> { static constexpr auto value{Typ
template<> struct get_option_type<std::vector<std::string>> { static constexpr auto value{Type::Strings}; };
template<> struct get_option_type<Percentage> { static constexpr auto value{Type::Percent}; };
template<> struct get_option_type<std::vector<Percentage>> { static constexpr auto value{Type::Percents}; };
template<> struct get_option_type<FloatOrPercentage> { static constexpr auto value{Type::FloatOrPercent}; };
template<> struct get_option_type<std::vector<FloatOrPercentage>> { static constexpr auto value{Type::FloatsOrPercents}; };
template<> struct get_option_type<Vec2d> { static constexpr auto value{Type::Point}; };
template<> struct get_option_type<std::vector<Vec2d>> { static constexpr auto value{Type::Points}; };
template<> struct get_option_type<bool> { static constexpr auto value{Type::Bool}; };
@ -64,29 +56,24 @@ constexpr Type get_option_type_v = get_option_type<T>::value;
template<typename T>
requires (!std::is_enum_v<T>)
Scalar::Scalar(const T& value, const std::string& ratio_over) : m_ratio_over{ratio_over}
Scalar::Scalar(const T& value)
{
constexpr auto type{get_option_type_v<T>};
static_assert(type != Type::None, "Unknown type passed to set");
if (type != Type::Percent && type != Type::FloatOrPercent) {
ASSERT(ratio_over.empty(), "Ration over can only be defined for percent values");
}
m_value = value;
m_type = type;
}
template Scalar::Scalar(const double&, const std::string&);
template Scalar::Scalar(const int&, const std::string&);
template Scalar::Scalar(const std::optional<int>&, const std::string&);
template Scalar::Scalar(const std::optional<double>&, const std::string&);
template Scalar::Scalar(const std::optional<std::string>&, const std::string&);
template Scalar::Scalar(const std::optional<bool>&, const std::string&);
template Scalar::Scalar(const std::string&, const std::string&);
template Scalar::Scalar(const Percentage&, const std::string&);
template Scalar::Scalar(const FloatOrPercentage&, const std::string&);
template Scalar::Scalar(const Vec2d&, const std::string&);
template Scalar::Scalar(const bool&, const std::string&);
template Scalar::Scalar(const double&);
template Scalar::Scalar(const int&);
template Scalar::Scalar(const std::optional<int>&);
template Scalar::Scalar(const std::optional<double>&);
template Scalar::Scalar(const std::optional<std::string>&);
template Scalar::Scalar(const std::optional<bool>&);
template Scalar::Scalar(const std::string&);
template Scalar::Scalar(const Percentage&);
template Scalar::Scalar(const Vec2d&);
template Scalar::Scalar(const bool&);
Scalar Scalar::init_enum(const int value, const std::string& serialized_value) {
Scalar result{value};
@ -105,7 +92,6 @@ bool Scalar::operator==(const Scalar& rhs) const {
case Type::Int: return get<int>() == rhs.get<int>();
case Type::String: return get<std::string>() == rhs.get<std::string>();
case Type::Percent: return get<Percentage>() == rhs.get<Percentage>();
case Type::FloatOrPercent: return get<FloatOrPercentage>() == rhs.get<FloatOrPercentage>();
case Type::Point: return get<Vec2d>().isApprox(rhs.get<Vec2d>());
case Type::Bool: return get<bool>() == rhs.get<bool>();
case Type::Enum: return get<int>() == rhs.get<int>();
@ -129,11 +115,6 @@ std::string Scalar::serialize() const {
const auto result{get<Percentage>()};
return float_to_string_decimal_point(result.value) + "%";
}
case Type::FloatOrPercent: {
const auto result{get<FloatOrPercentage>()};
const std::string value_string{float_to_string_decimal_point(result.get_abs_value(100.0))};
return result.is_percentage() ? value_string + "%" : value_string;
}
case Type::Point: {
const auto result{get<Vec2d>()};
return float_to_string_decimal_point(result.x()) + "," +
@ -148,8 +129,6 @@ std::string Scalar::serialize() const {
}
}
std::string Scalar::ratio_over() const { return m_ratio_over; }
template<typename T>
requires (!std::is_enum_v<T>)
T Scalar::get() const
@ -167,7 +146,6 @@ template std::optional<std::string> Scalar::get() const;
template std::optional<bool> Scalar::get() const;
template std::string Scalar::get() const;
template Percentage Scalar::get() const;
template FloatOrPercentage Scalar::get() const;
template Vec2d Scalar::get() const;
template bool Scalar::get() const;
@ -190,7 +168,6 @@ template Vector::Vector(const std::vector<std::optional<std::string>>&);
template Vector::Vector(const std::vector<std::optional<bool>>&);
template Vector::Vector(const std::vector<std::string>&);
template Vector::Vector(const std::vector<Percentage>&);
template Vector::Vector(const std::vector<FloatOrPercentage>&);
template Vector::Vector(const std::vector<Vec2d>&);
template Vector::Vector(const std::vector<bool>&);
@ -224,7 +201,6 @@ template std::vector<std::optional<std::string>> Vector::get() const;
template std::vector<std::optional<bool>> Vector::get() const;
template std::vector<std::string> Vector::get() const;
template std::vector<Percentage> Vector::get() const;
template std::vector<FloatOrPercentage> Vector::get() const;
template std::vector<Vec2d> Vector::get() const;
template std::vector<bool> Vector::get() const;
@ -273,7 +249,6 @@ template void Config::set(const std::string&, const std::optional<std::string>&)
template void Config::set(const std::string&, const std::optional<bool>&);
template void Config::set(const std::string&, const std::string&);
template void Config::set(const std::string&, const Percentage&);
template void Config::set(const std::string&, const FloatOrPercentage&);
template void Config::set(const std::string&, const Vec2d&);
template void Config::set(const std::string&, const bool&);
template void Config::set(const std::string&, const std::vector<double>&);
@ -284,7 +259,6 @@ template void Config::set(const std::string&, const std::vector<std::optional<do
template void Config::set(const std::string&, const std::vector<std::optional<std::string>>&);
template void Config::set(const std::string&, const std::vector<std::string>&);
template void Config::set(const std::string&, const std::vector<Percentage>&);
template void Config::set(const std::string&, const std::vector<FloatOrPercentage>&);
template void Config::set(const std::string&, const std::vector<Vec2d>&);
template void Config::set(const std::string&, const std::vector<bool>&);
@ -355,61 +329,32 @@ void copy(const std::string& name, const ConfigValue& value, Config& config)
std::vector<std::string> enum_values;
enum_values.insert(enum_values.end(), values.begin(), values.end());
config.set(name, enum_values);
} else if constexpr (std::is_same_v<ValueType, Domain::FloatOrPercentage>)
{
ASSERT(!item_value.is_percentage());
config.set(name, item_value.float_value());
} else if constexpr (std::is_same_v<ValueType, std::vector<Domain::FloatOrPercentage>>)
{
std::vector<double> values;
for (const Domain::FloatOrPercentage& value : item_value) {
ASSERT(!value.is_percentage());
values.push_back(value.float_value());
}
config.set(name, values);
} else {
config.set(name, item_value);
}
});
}
std::vector<double> get_nozzle_diameters(const Domain::Preset::HwPrinterConfig& hw_config)
{
std::vector<double> result;
for (const auto& tool : hw_config.tools) {
const std::optional<double> nozzle_diameter{
Domain::Preset::get_feature<double>(tool.features, "nozzle_diameter")
};
ASSERT(nozzle_diameter);
result.push_back(*nozzle_diameter);
}
return result;
}
std::vector<bool> get_nozzle_high_flows(const Domain::Preset::HwPrinterConfig& hw_config)
{
std::vector<bool> result;
for (const auto& tool : hw_config.tools) {
const std::optional<bool> high_flow{
Domain::Preset::get_feature<bool>(tool.features, "nozzle_high_flow")
};
result.push_back(high_flow.value_or(false));
}
return result;
}
} // namespace
Config get_parser_config(const FullConfigFDM& full_config)
Config get_parser_config(const ConfigView& config_view)
{
Config result;
for (const auto& [key, value] : full_config.values()) {
for (const auto& [key, value] : config_view.values()) {
copy(key, value, result);
}
result.set("nozzle_diameter", get_nozzle_diameters(full_config.hw_config()));
result.set("nozzle_high_flow", get_nozzle_high_flows(full_config.hw_config()));
return result;
}
Config get_parser_config(const FullConfigSLA& full_config)
{
Config result;
for (const auto& [key, value] : full_config.values()) {
copy(key, value, result);
}
return result;
}

View file

@ -1017,46 +1017,6 @@ namespace client
case IO::Type::Enum:
case IO::Type::Point: output.set_s(scalar.serialize()); break;
case IO::Type::Bool: output.set_b(scalar.get<bool>()); break;
case IO::Type::FloatOrPercent:
{
std::string opt_key(opt.it_range.begin(), opt.it_range.end());
const auto float_or_percent{scalar.get<Domain::FloatOrPercentage>()};
if (! float_or_percent.is_percentage()) {
// Not a percent, just return the value.
output.set_d(float_or_percent.float_value());
} else {
// Resolve dependencies using the "ratio_over" link to a parent value.
double v = scalar.get<Domain::FloatOrPercentage>().get_abs_value(1.0); // percent to ratio
//
std::string parent_name{scalar.ratio_over()};
const IO::Value *opt_parent = parent_name.empty() ? nullptr : ctx->resolve_symbol(parent_name);
for (;;) {
if (opt_parent == nullptr)
ctx->throw_exception("FloatOrPercent variable failed to resolve the \"ratio_over\" dependencies", opt.it_range);
const auto parent_value = std::get<IO::Scalar>(*opt_parent);
if (parent_value.type() == IO::Type::Float) {
v *= parent_value.get<double>();
break;
} else if (parent_value.type() == IO::Type::FloatOrPercent) {
const auto value{parent_value.get<Domain::FloatOrPercentage>()};
if (!value.is_percentage()) {
v *= value.float_value();
break;
}
v *= value.get_abs_value(1.0);
}
// Continue one level up in the "ratio_over" hierarchy.
parent_name = parent_value.ratio_over();
opt_parent = ctx->resolve_symbol(parent_name);
assert(opt_parent != nullptr);
}
output.set_d(v);
}
break;
}
default:
ctx->throw_exception("Unsupported scalar variable type", opt.it_range);
}

View file

@ -1,7 +1,6 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_vector.hpp>
#include "Slic3r/Biz/Parser/IO.hpp"
#include "Slic3r/Domain/Config.hpp"
#include "Slic3r/Domain/Types.hpp"
using namespace Catch;
@ -14,7 +13,6 @@ using Slic3r::Biz::Parser::IO::Value;
using Slic3r::Biz::Parser::IO::Vector;
using Slic3r::Biz::Parser::IO::Scalar;
using Slic3r::Domain::Percentage;
using Slic3r::Domain::FloatOrPercentage;
using Slic3r::Domain::Vec2d;
TEST_CASE("Vector is stored if std::vector<int> is passed to config", "[ParserIO]") {
@ -38,7 +36,6 @@ TEST_CASE("Scalar is stored if Perecentage is passed to config", "[ParserIO]") {
REQUIRE(is_scalar(value));
const Scalar& scalar{std::get<Scalar>(value)};
CHECK(scalar.type() == Type::Percent);
CHECK(scalar.ratio_over() == "");
CHECK(scalar.get<Percentage>() == data);
}
@ -69,8 +66,6 @@ TEST_CASE("Scalar can be serialized to string", "[ParserIO]") {
CHECK(Scalar{std::optional<int>{}}.serialize() == "nil");
CHECK(Scalar{std::string{"hello\r\n\\"}}.serialize() == "hello\r\n\\");
CHECK(Scalar{Percentage{10}}.serialize() == "10%");
CHECK(Scalar{FloatOrPercentage{Percentage{30}}}.serialize() == "30%");
CHECK(Scalar{FloatOrPercentage{3.3}}.serialize() == "3.3");
CHECK(Scalar{Vec2d{12.3, 4.56}}.serialize() == "12.3,4.56");
CHECK(Scalar{true}.serialize() == "1");
CHECK(Scalar{false}.serialize() == "0");

View file

@ -2,14 +2,11 @@
#include <catch2/catch_approx.hpp>
#include "Slic3r/Biz/Parser/PlaceholderParser.hpp"
#include "Slic3r/Domain/Config.hpp"
using namespace Catch;
using Slic3r::Biz::Parser::PlaceholderParser;
using Slic3r::Biz::Parser::IO::Config;
using Slic3r::Domain::Percentage;
using Slic3r::Domain::FloatOrPercentage;
using Slic3r::Biz::Parser::IO::Vector;
using Slic3r::Biz::Parser::IO::Scalar;
using Slic3r::Biz::Parser::IO::Value;
@ -24,7 +21,6 @@ TEST_CASE("Placeholder parser scripting", "[PlaceholderParser]") {
config.set("printer_notes", std::string{" PRINTER_VENDOR_PRUSA3D PRINTER_MODEL_MK2 "});
config.set("nozzle_diameter", std::vector<double>{0.6, 0.6, 0.6, 0.6});
config.set("temperature", std::vector<int>{357, 359, 363, 378});
config.set("first_layer_speed", FloatOrPercentage{Percentage{50}});
config.set("idle_temperature", std::vector<std::optional<int>>{100, std::nullopt, 200});
PlaceholderParser parser;
@ -106,25 +102,6 @@ TEST_CASE("Placeholder parser scripting", "[PlaceholderParser]") {
SECTION("math: interpolate_table(13, (0, 0), (20, 20), (30, 20))") { REQUIRE(std::stod(parser.process("{interpolate_table(13, (0, 0), (20, 20), (30, 20))}")) == Approx(13.)); }
SECTION("math: interpolate_table(25, (0, 0), (20, 20), (30, 20))") { REQUIRE(std::stod(parser.process("{interpolate_table(25, (0, 0), (20, 20), (30, 20))}")) == Approx(20.)); }
parser.set("layer_height", 0.2);
parser.set("perimeter_extrusion_width", Value{Scalar{FloatOrPercentage{Percentage{50}}, "layer_height"}});
parser.set("first_layer_height", Value{Scalar{FloatOrPercentage{Percentage{200}}, "layer_height"}});
parser.set("first_layer_extrusion_width", Value{Scalar{FloatOrPercentage{Percentage{50}}, "first_layer_height"}});
parser.set("external_perimeter_extrusion_width", 0.5);
parser.set("support_material_xy_spacing", Value{Scalar{FloatOrPercentage{Percentage{50}}, "external_perimeter_extrusion_width"}});
// Test the "coFloatOrPercent" and "xxx_extrusion_width" substitutions.
// first_layer_extrusion_width ratio_over first_layer_heigth.
SECTION("perimeter_extrusion_width") { REQUIRE(std::stod(parser.process("{perimeter_extrusion_width}")) == Approx(0.1)); }
SECTION("first_layer_extrusion_width") { REQUIRE(std::stod(parser.process("{first_layer_extrusion_width}")) == Approx(0.2)); }
SECTION("support_material_xy_spacing") { REQUIRE(std::stod(parser.process("{support_material_xy_spacing}")) == Approx(0.25)); }
parser.set("first_layer_speed", FloatOrPercentage{Percentage{50}});
// If first_layer_speed is set to percent, then it is applied over respective extrusion types by overriding their respective speeds.
// The PlaceholderParser has no way to know which extrusion type the caller has in mind, therefore it throws.
SECTION("first_layer_speed") { REQUIRE_THROWS(parser.process("{first_layer_speed}")); }
// Test the boolean expression parser.
auto boolean_expression = [&parser](const std::string& templ) { return parser.evaluate_boolean_expression(templ, parser.config()); };

View file

@ -106,12 +106,18 @@ add_library(slic3r-domain STATIC
include/Slic3r/Domain/Config.hpp
src/Slic3r/Domain/Config.cpp
include/Slic3r/Domain/ConfigDefsFDM.hpp
src/Slic3r/Domain/ConfigDefsFDM.cpp
include/Slic3r/Domain/ConfigBoxesFDM.hpp
src/Slic3r/Domain/ConfigBoxesFDM.cpp
include/Slic3r/Domain/FullConfigFDM.hpp
src/Slic3r/Domain/FullConfigFDM.cpp
include/Slic3r/Domain/ConfigDefsSLA.hpp
src/Slic3r/Domain/ConfigDefsSLA.cpp
include/Slic3r/Domain/ConfigBoxesSLA.hpp
src/Slic3r/Domain/ConfigBoxesSLA.cpp
@ -206,8 +212,11 @@ endif()
if(SLIC3R_BUILD_TESTS)
add_executable(slic3r-domain-tests
test/Slic3r/Domain/TestUtils.hpp
test/Slic3r/Domain/TestUtils.cpp
test/Slic3r/Domain/ConfigValueTests.cpp
test/Slic3r/Domain/ConfigTests.cpp
test/Slic3r/Domain/FDMConfigTests.cpp
test/Slic3r/Domain/Preset/PresetTreeTests.cpp
test/Slic3r/Domain/Preset/HwConfigTests.cpp
test/Slic3r/Domain/SizeTests.cpp

View file

@ -12,6 +12,7 @@
#include "Slic3r/Domain/ConfigValue.hpp"
#include "Slic3r/Domain/ConfigDef.hpp"
#include "Slic3r/Domain/Preset/HwConfig.hpp"
namespace Slic3r::Domain {
// A wrapper type for a single config item. Not polymorphic, not templated. The caller
@ -187,12 +188,6 @@ using MutBoxRef = std::reference_wrapper<ConfigBox>;
using MutBoxRefs = std::vector<MutBoxRef>;
using MutBoxOrBoxesVector = std::vector<std::variant<MutBoxRef, MutBoxRefs>>;
using LocationSize = std::optional<std::size_t>;
using ConfigLocationSizes = std::map<ConfigLocation, LocationSize>;
using CompatibilityRules = std::map<std::string, CompatibilityRule>;
const CompatibilityRules& get_compatibility_rules();
/* @param default_value: Used if any of the items is nullptr. Might be nullptr,
* but then all the item values need to be specified.
*
@ -222,9 +217,11 @@ public:
SquashedConfig(
const BoxOrBoxesVector& boxes,
const std::vector<unsigned>& extruder_candidates,
const ConfigLocationSizes& sizes
const Preset::HwPrinterConfig& hw_config
);
const Preset::HwPrinterConfig& hw_config() const;
std::vector<std::string> diff_keys(const SquashedConfig& other) const;
bool operator==(const SquashedConfig& other) const;
@ -242,16 +239,14 @@ public:
std::size_t hash() const;
const std::map<std::string, ConfigValue>& original_values() const;
const std::vector<unsigned>& extruder_candidates() const;
protected:
std::map<std::string, ConfigValue> m_values;
private:
void add(const ConfigBox& box, const ConfigLocationSizes& location_sizes);
void add(
const BoxRefs& boxes,
const std::vector<unsigned>& extruder_candidates,
const ConfigLocationSizes& location_sizes
);
std::map<std::string, ConfigValue> m_original_values;
Preset::HwPrinterConfig m_hw_config;
std::vector<unsigned> m_extruder_candidates;
};
class FullConfig : public SquashedConfig {
@ -270,7 +265,7 @@ protected:
FullConfig(
const BoxOrBoxesVector& input,
const std::vector<unsigned>& extruder_candidates,
const ConfigLocationSizes& location_sizes
const Preset::HwPrinterConfig& hw_config
);
private:
@ -293,7 +288,7 @@ public:
protected:
PartialConfig(
const BoxOrBoxesVector& input,
const ConfigLocationSizes& location_sizes
const Preset::HwPrinterConfig& hw_config
);
private:
@ -312,22 +307,33 @@ public:
template<class T>
T get(const std::string& key) const {
return get_value(key).get<T>();
ASSERT(m_finalized);
const auto it{m_values.find(key)};
ASSERT(it != m_values.end());
return it->second.get<T>();
}
bool operator==(const ConfigView& other) const;
void finalize();
const std::map<std::string, ConfigValue>& values() const;
std::size_t hash() const;
std::vector<std::string> diff_keys(const ConfigView& other) const;
const Domain::Preset::HwPrinterConfig& hw_config() const;
protected:
bool m_finalized{false};
FullConfigPtr m_full_config;
std::vector<PartialConfigPtr> m_partial_configs;
std::vector<std::string> m_keys;
std::map<std::string, ConfigValue> m_values;
Domain::Preset::HwPrinterConfig m_hw_config;
private:
ConfigValue get_value(const std::string& key) const;
ConfigValue resolve_value(const std::string& key) const;
};
} // namespace Slic3r::Domain

View file

@ -1,116 +1,9 @@
#pragma once
#include "Slic3r/Domain/Config.hpp"
#include "Slic3r/Domain/GCodeFlavor.hpp"
#include "Slic3r/Domain/ConfigCommon.hpp"
namespace Slic3r::Domain {
// This is an example of using Config infrastructure.
// Next, define all enums that should be used in the config.
enum class ArcFittingType {
Disabled,
EmitCenter
};
enum class CoolingSlowdownLogicType
{
UniformCooling,
ConsistentSurface,
Proportional,
};
enum class TopOnePerimeterType
{
None,
TopSurfaces,
TopmostOnly,
Count
};
enum class BrimType {
NoBrim,
OuterOnly,
InnerOnly,
OuterAndInner,
};
enum class EnsureVerticalShellThickness {
Disabled,
Partial,
Enabled,
};
enum class InfillPattern {
ipRectilinear, ipMonotonic, ipMonotonicLines, ipAlignedRectilinear, ipGrid, ipTriangles,
ipStars, ipCubic, ipLine, ipConcentric, ipHoneycomb, ip3DHoneycomb, ipGyroid, ipHilbertCurve,
ipArchimedeanChords, ipOctagramSpiral, ipAdaptiveCubic, ipSupportCubic, ipSupportBase,
ipLightning, ipEnsuring, ipZigZag, ipCount,
};
enum class FuzzySkinType {
None,
External,
All,
};
enum class LabelObjectsStyle {
Disabled, Octoprint, Firmware
};
enum class IroningType {
TopSurfaces,
TopmostOnly,
AllSolid,
Count,
};
enum class MachineLimitsUsage {
EmitToGCode,
TimeEstimateOnly,
Ignore,
Count,
};
enum class SeamPosition {
spRandom, spNearest, spAligned, spRear
};
enum class ScarfSeamPlacement {
nowhere,
countours,
everywhere
};
enum class DraftShield {
dsDisabled, dsLimited, dsEnabled
};
enum class SupportMaterialPattern {
smpRectilinear, smpRectilinearGrid, smpHoneycomb,
};
enum class SupportMaterialInterfacePattern {
smipAuto, smipRectilinear, smipConcentric,
};
enum class SupportMaterialStyle {
smsGrid, smsSnug, smsTree, smsOrganic,
};
enum class PerimeterGeneratorType
{
Classic, // Classic perimeter generator using Clipper offsets with constant extrusion width.
Arachne // Perimeter generator with variable extrusion width based on the paper "A framework for
// "adaptive width control of dense contour-parallel toolpaths in fused deposition modeling" ported from Cura.
};
enum class SupportMode
{
None,
EnforcersOnly,
Everywhere,
};
enum class PressureAdvance
{
Disabled,
Enabled,
AutomaticCalibration,
};
enum class ToolChangeOrderingType
{
Optimized,
Cyclic,
};
// Then, define all types of ConfigBoxes that will be used. Provide our list
// of definitions and the type of the box (which must match definitions).

View file

@ -1,58 +1,9 @@
#pragma once
#include "Slic3r/Domain/Config.hpp"
#include "Slic3r/Domain/ConfigCommon.hpp"
namespace Slic3r::Domain {
// Next, define all enums that should be used in the config.
enum class SLADisplayOrientation {
sladoLandscape,
sladoPortrait
};
enum SLAMaterialSpeed { slamsSlow, slamsFast, slamsHighViscosity };
namespace sla {
enum class SupportTreeType { Default, Branching, Organic };
enum class PillarConnectionMode { zigzag, cross, dynamic };
}
enum TowerSpeeds : int {
tsLayer1,
tsLayer2,
tsLayer3,
tsLayer4,
tsLayer5,
tsLayer8,
tsLayer11,
tsLayer14,
tsLayer18,
tsLayer22,
tsLayer24,
};
enum TiltSpeeds : int {
tsMove120,
tsLayer200,
tsMove300,
tsLayer400,
tsLayer600,
tsLayer800,
tsLayer1000,
tsLayer1250,
tsLayer1500,
tsLayer1750,
tsLayer2000,
tsLayer2250,
tsMove5120,
tsMove8000,
};
// Then, define all types of ConfigBoxes that will be used. Provide our list
// of definitions and the type of the box (which must match definitions).

View file

@ -36,6 +36,15 @@ enum class SLAConfigLocation
Object,
};
enum class CompatibilityRule
{
Undefined,
IgnoreOverrides,
Min,
Max,
Average
};
struct PhysicalPrinterLocation {
bool operator==(const PhysicalPrinterLocation&) const = default;
bool operator<(const PhysicalPrinterLocation&) const {
@ -73,6 +82,7 @@ struct ConfigItemDef
std::function<ConfigValue(const ConfigLocation& config_location)> init_fn_ex;
ConfigLocation location; // Which box it belongs to. Must not be empty.
std::set<ConfigLocation> overrides_in; // Which boxes this can be overridden in.
std::string ratio_over;
// Non-translated Label of the GUI input field. In case the GUI input fields are grouped in some views,
// the label defines a short label of a grouped value, while full_label contains a label of a stand-alone field.
@ -346,7 +356,7 @@ struct ConfigItemDef
// The backend expects a single option, but it can be specified multiple times on the frontend.
// Hence a compatibility rule needs to be specified to obtain a single value from multiple.
bool require_compatibility_rule = false;
CompatibilityRule compatibility_rule = CompatibilityRule::Undefined;
static constexpr const char* nocli = "~~nocli";
@ -426,13 +436,4 @@ private:
bool m_finalized{false};
std::set<ConfigLocation> m_acceptable_boxes;
};
enum class CompatibilityRule
{
Undefined,
IgnoreOverrides,
Min,
Max,
Average
};
} // namespace Slic3r::Domain

View file

@ -0,0 +1,113 @@
#pragma once
#include "Slic3r/Domain/ConfigDef.hpp"
namespace Slic3r::Domain {
// This is an example of using Config infrastructure.
// Next, define all enums that should be used in the config.
enum class ArcFittingType {
Disabled,
EmitCenter
};
enum class CoolingSlowdownLogicType
{
UniformCooling,
ConsistentSurface,
Proportional,
};
enum class TopOnePerimeterType
{
None,
TopSurfaces,
TopmostOnly,
Count
};
enum class BrimType {
NoBrim,
OuterOnly,
InnerOnly,
OuterAndInner,
};
enum class EnsureVerticalShellThickness {
Disabled,
Partial,
Enabled,
};
enum class InfillPattern {
ipRectilinear, ipMonotonic, ipMonotonicLines, ipAlignedRectilinear, ipGrid, ipTriangles,
ipStars, ipCubic, ipLine, ipConcentric, ipHoneycomb, ip3DHoneycomb, ipGyroid, ipHilbertCurve,
ipArchimedeanChords, ipOctagramSpiral, ipAdaptiveCubic, ipSupportCubic, ipSupportBase,
ipLightning, ipEnsuring, ipZigZag, ipCount,
};
enum class FuzzySkinType {
None,
External,
All,
};
enum class LabelObjectsStyle {
Disabled, Octoprint, Firmware
};
enum class IroningType {
TopSurfaces,
TopmostOnly,
AllSolid,
Count,
};
enum class MachineLimitsUsage {
EmitToGCode,
TimeEstimateOnly,
Ignore,
Count,
};
enum class SeamPosition {
spRandom, spNearest, spAligned, spRear
};
enum class ScarfSeamPlacement {
nowhere,
countours,
everywhere
};
enum class DraftShield {
dsDisabled, dsLimited, dsEnabled
};
enum class SupportMaterialPattern {
smpRectilinear, smpRectilinearGrid, smpHoneycomb,
};
enum class SupportMaterialInterfacePattern {
smipAuto, smipRectilinear, smipConcentric,
};
enum class SupportMaterialStyle {
smsGrid, smsSnug, smsTree, smsOrganic,
};
enum class PerimeterGeneratorType
{
Classic, // Classic perimeter generator using Clipper offsets with constant extrusion width.
Arachne // Perimeter generator with variable extrusion width based on the paper "A framework for
// "adaptive width control of dense contour-parallel toolpaths in fused deposition modeling" ported from Cura.
};
enum class SupportMode
{
None,
EnforcersOnly,
Everywhere,
};
enum class PressureAdvance
{
Disabled,
Enabled,
AutomaticCalibration,
};
enum class ToolChangeOrderingType
{
Optimized,
Cyclic,
};
const ConfigDefinitions& get_defs_fdm();
} // namespace Slic3r::Domain

View file

@ -0,0 +1,52 @@
#pragma once
#include "Slic3r/Domain/ConfigDef.hpp"
namespace Slic3r::Domain {
// Next, define all enums that should be used in the config.
enum class SLADisplayOrientation {
sladoLandscape,
sladoPortrait
};
enum SLAMaterialSpeed { slamsSlow, slamsFast, slamsHighViscosity };
namespace sla {
enum class SupportTreeType { Default, Branching, Organic };
enum class PillarConnectionMode { zigzag, cross, dynamic };
}
enum TowerSpeeds : int {
tsLayer1,
tsLayer2,
tsLayer3,
tsLayer4,
tsLayer5,
tsLayer8,
tsLayer11,
tsLayer14,
tsLayer18,
tsLayer22,
tsLayer24,
};
enum TiltSpeeds : int {
tsMove120,
tsLayer200,
tsMove300,
tsLayer400,
tsLayer600,
tsLayer800,
tsLayer1000,
tsLayer1250,
tsLayer1500,
tsLayer1750,
tsLayer2000,
tsLayer2250,
tsMove5120,
tsMove8000,
};
const ConfigDefinitions& get_defs_sla();
} // namespace Slic3r::Domain

View file

@ -60,8 +60,6 @@ inline const EnumValueDefs* check_enum_def(const EnumValueDefs* def) {
struct EnumVectorWrapper
{
EnumVectorWrapper() = delete;
template<typename T>
EnumVectorWrapper(const T& values, const EnumValueDefs* def)
: m_values{to_ints(values)}
@ -97,10 +95,13 @@ struct EnumVectorWrapper
std::vector<size_t> get_indexes() const;
void set_indexes(const std::vector<size_t>& indexes);
std::vector<int>& raw();
const std::type_info* type() const;
const std::vector<int>& values() const;
const EnumValueDefs& def() const;
bool operator==(const EnumVectorWrapper&) const;
private:
@ -121,8 +122,6 @@ private:
struct EnumWrapper
{
EnumWrapper() = delete;
template<typename T>
explicit EnumWrapper(const T& value, const EnumValueDefs* def)
: m_value{static_cast<int>(value)}, m_type{&typeid(T)}, m_def{check_enum_def(def)}
@ -168,22 +167,12 @@ private:
};
struct ConfigValue {
ConfigValue() = delete;
template <typename T>
explicit ConfigValue(const T& value): m_value{value} {}
ConfigValue() = default;
explicit ConfigValue(const char* str);
ConfigValue(const ConfigValue& other);
ConfigValue(ConfigValue&& other) noexcept;
ConfigValue& operator=(const ConfigValue& other);
ConfigValue& operator=(ConfigValue&& other) noexcept;
~ConfigValue();
template <typename T>
explicit ConfigValue(const T& value): m_value{value} {}
template <typename T>
requires (!std::is_enum_v<T> && !Impl::is_enum_vector<T>())
@ -287,7 +276,5 @@ private:
std::vector<FloatOrPercentage>,
std::vector<Percentage>
> m_value{bool{}};
static void assert_types_equal(const ConfigValue& a, const ConfigValue& b);
};
}

View file

@ -20,55 +20,14 @@ public:
const Preset::HwPrinterConfig& hw_config
);
const Preset::HwPrinterConfig& hw_config() const {
return m_hw_config;
}
static FullConfigFDM defaults() {
Preset::HwToolConfig tool_config;
Preset::HwPrinterConfig hw_config{
.id = generate_uuid(),
.printer_id = {},
.legacy_printer_model = {},
.vendor_id = {},
.repo_id = {},
.repo_version = {},
.name = {},
.short_name = {},
.technology = PrinterTechnology::FFF,
.model = {},
.tool_count = 1,
.features = {},
.visual = {},
.tools = {1, Preset::HwToolConfig{}},
.feeders = {
{Preset::Address{0},
Preset::HwFeederConfig{
.id = generate_uuid(),
.type = Preset::FeederType::Manual,
.model = {},
.slot_count = 1,
.features = {}
}}
},
.materials = {},
.sheet = {}
};
return {ConfigPackFDM{}, {0}, hw_config};
}
private:
Preset::HwPrinterConfig m_hw_config;
static FullConfigFDM defaults();
};
class PartialObjectConfigFDM : public PartialConfig {
public:
PartialObjectConfigFDM(
const ObjectSettings& object_settings,
const std::size_t material_slot_count
const Preset::HwPrinterConfig& hw_config
);
};
@ -76,7 +35,7 @@ class PartialVolumeConfigFDM : public PartialConfig {
public:
PartialVolumeConfigFDM(
const VolumeSettings& volume_settings,
const std::size_t material_slot_count
const Preset::HwPrinterConfig& hw_config
);
};

View file

@ -12,17 +12,18 @@ BoxOrBoxesVector as_boxes(const ConfigPackSLA& config_pack);
class FullConfigSLA : public FullConfig
{
public:
FullConfigSLA(const ConfigPackSLA& config_pack);
FullConfigSLA(const ConfigPackSLA& config_pack, const Preset::HwPrinterConfig& hw_config);
static FullConfigSLA defaults() {
return {ConfigPackSLA{}};
return {ConfigPackSLA{}, Preset::HwPrinterConfig{.technology = PrinterTechnology::SLA}};
}
};
class PartialObjectConfigSLA : public PartialConfig {
public:
PartialObjectConfigSLA(
const SLAObjectSettings& object_settings
const SLAObjectSettings& object_settings,
const Preset::HwPrinterConfig& hw_config
);
};

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -88,7 +88,7 @@ void init_common_fdm_sla_config_items(ConfigDefinitions& defs, const PrinterTech
}
if (technology == FFF) {
def->location = FDMConfigLocation::Print;
def->require_compatibility_rule = true;
def->compatibility_rule = CompatibilityRule::Average;
def->overrides_in = Locations{ fdm_tool, fdm_object, fdm_volume };
def->option_group = ConfigItemDef::OptionGroup::Print_PrecisionSlicing_DimensionalAccuracy;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -69,6 +69,11 @@ void EnumVectorWrapper::set_indexes(const std::vector<size_t>& indexes)
}
}
std::vector<int>& EnumVectorWrapper::raw()
{
return m_values;
}
bool EnumVectorWrapper::operator==(const EnumVectorWrapper&) const = default;
void EnumWrapper::set_string(const std::string& value)
@ -126,27 +131,6 @@ bool EnumWrapper::operator==(const EnumWrapper&) const = default;
ConfigValue::ConfigValue(const char* str): ConfigValue(std::string{str}) {}
ConfigValue::ConfigValue(const ConfigValue& other) :
m_value{other.m_value}
{}
ConfigValue::ConfigValue(ConfigValue&& other) noexcept :
m_value{std::move(other.m_value)}
{}
ConfigValue& ConfigValue::operator=(const ConfigValue& other) {
assert_types_equal(*this, other);
m_value = other.m_value;
return *this;
}
ConfigValue& ConfigValue::operator=(ConfigValue&& other) noexcept {
assert_types_equal(*this, other);
m_value = std::move(other.m_value);
return *this;
}
ConfigValue::~ConfigValue() = default;
namespace {
@ -200,60 +184,4 @@ bool ConfigValue::operator==(const ConfigValue& rhs) const
);
}
void ConfigValue::assert_types_equal(const ConfigValue& a, const ConfigValue& b) {
// TODO: Vectors are now "convertible" to scalars, to allow backend to have scalars where it used to have them.
// This is a temporary hack, until we solve the issue with backend using scalar values in places
// where there are now vectors.
if (std::holds_alternative<EnumVectorWrapper>(a.m_value)) {
ASSERT(a.m_value.index() == b.m_value.index() || std::holds_alternative<EnumWrapper>(b.m_value));
return;
}
if (std::holds_alternative<std::vector<bool>>(a.m_value)) {
ASSERT(a.m_value.index() == b.m_value.index() || std::holds_alternative<bool>(b.m_value));
return;
}
if (std::holds_alternative<std::vector<int>>(a.m_value)) {
ASSERT(a.m_value.index() == b.m_value.index() || std::holds_alternative<int>(b.m_value));
return;
}
if (std::holds_alternative<std::vector<std::optional<int>>>(a.m_value)) {
ASSERT(a.m_value.index() == b.m_value.index() || std::holds_alternative<std::optional<int>>(b.m_value));
return;
}
if (std::holds_alternative<std::vector<double>>(a.m_value)) {
ASSERT(a.m_value.index() == b.m_value.index() || std::holds_alternative<double>(b.m_value));
return;
}
if (std::holds_alternative<std::vector<std::string>>(a.m_value)) {
ASSERT(a.m_value.index() == b.m_value.index() || std::holds_alternative<std::string>(b.m_value));
return;
}
if (std::holds_alternative<std::vector<Domain::Vec2d>>(a.m_value)) {
ASSERT(a.m_value.index() == b.m_value.index() || std::holds_alternative<Domain::Vec2d>(b.m_value));
return;
}
if (std::holds_alternative<std::vector<FloatOrPercentage>>(a.m_value)) {
ASSERT(a.m_value.index() == b.m_value.index() || std::holds_alternative<FloatOrPercentage>(b.m_value));
return;
}
if (std::holds_alternative<std::vector<Percentage>>(a.m_value)) {
ASSERT(a.m_value.index() == b.m_value.index() || std::holds_alternative<Percentage>(b.m_value));
return;
}
ASSERT(a.m_value.index() == b.m_value.index(), "Only a value of the same type can be assigned to ConfigItem!");
if (std::holds_alternative<EnumWrapper>(a.m_value)) {
ASSERT(
std::get<EnumWrapper>(a.m_value).type() == std::get<EnumWrapper>(b.m_value).type(),
"Enum types must be the same!"
);
}
if (std::holds_alternative<EnumVectorWrapper>(a.m_value)) {
ASSERT(
std::get<EnumVectorWrapper>(a.m_value).type() == std::get<EnumVectorWrapper>(b.m_value).type(),
"Types of enums in vector must be the same!"
);
}
}
}

View file

@ -25,7 +25,6 @@ MutBoxRefs convert_to_mut_box_refs(
}
BoxOrBoxesVector as_boxes(const ConfigPackFDM& config_pack) {
ASSERT(config_pack.filament.size() == config_pack.tool.size() || config_pack.tool.size() == 1);
BoxOrBoxesVector result;
result.push_back(config_pack.print);
result.push_back(convert_to_box_refs(config_pack.tool));
@ -36,7 +35,6 @@ BoxOrBoxesVector as_boxes(const ConfigPackFDM& config_pack) {
}
MutBoxOrBoxesVector as_mut_boxes(ConfigPackFDM& config_pack) {
ASSERT(config_pack.filament.size() == config_pack.tool.size() || config_pack.tool.size() == 1);
MutBoxOrBoxesVector result;
result.push_back(config_pack.print);
result.push_back(convert_to_mut_box_refs(config_pack.tool));
@ -46,50 +44,56 @@ MutBoxOrBoxesVector as_mut_boxes(ConfigPackFDM& config_pack) {
return result;
}
namespace {
ConfigLocationSizes get_fdm_location_sizes(const std::size_t material_slot_count) {
return {
{FDMConfigLocation::Print, std::nullopt},
{FDMConfigLocation::Tool, material_slot_count},
{FDMConfigLocation::Printer, std::nullopt},
{FDMConfigLocation::Filament, material_slot_count},
{FDMConfigLocation::Project, std::nullopt},
{FDMConfigLocation::Object, std::nullopt},
{FDMConfigLocation::Volume, std::nullopt}
};
}
}
FullConfigFDM::FullConfigFDM(
const ConfigPackFDM& config_pack,
const std::vector<unsigned>& extruder_candidates,
const Preset::HwPrinterConfig& hw_config
) :
FullConfig{
as_boxes(config_pack),
extruder_candidates,
get_fdm_location_sizes(hw_config.material_slot_count())
},
m_hw_config{hw_config}
const Preset::HwPrinterConfig& hw_config) :
FullConfig{as_boxes(config_pack), extruder_candidates, hw_config}
{}
FullConfigFDM FullConfigFDM::defaults()
{
Preset::HwToolConfig tool_config;
Preset::HwPrinterConfig hw_config{
.id = generate_uuid(),
.printer_id = {},
.legacy_printer_model = {},
.vendor_id = {},
.repo_id = {},
.repo_version = {},
.name = {},
.short_name = {},
.technology = PrinterTechnology::FFF,
.model = {},
.tool_count = 1,
.features = {},
.visual = {},
.tools = {1, Preset::HwToolConfig{.features = {{"nozzle_diameter", 0.4}}}},
.feeders = {},
.materials = {},
.sheet = {}};
return {ConfigPackFDM{}, {0}, hw_config};
}
PartialObjectConfigFDM::PartialObjectConfigFDM(
const ObjectSettings& object_settings,
const std::size_t material_slot_count
const Preset::HwPrinterConfig& hw_config
) :
PartialConfig{
{object_settings},
get_fdm_location_sizes(material_slot_count)
hw_config
}
{}
PartialVolumeConfigFDM::PartialVolumeConfigFDM(
const VolumeSettings& volume_settings,
const std::size_t material_slot_count
const Preset::HwPrinterConfig& hw_config
) :
PartialConfig{
{volume_settings},
get_fdm_location_sizes(material_slot_count)
hw_config
}
{}

View file

@ -10,24 +10,14 @@ BoxOrBoxesVector as_boxes(const ConfigPackSLA& config_pack) {
return result;
}
namespace {
ConfigLocationSizes get_sla_location_sizes() {
return {
{SLAConfigLocation::Printer, std::nullopt},
{SLAConfigLocation::Print, std::nullopt},
{SLAConfigLocation::Material, std::nullopt},
{SLAConfigLocation::Object, std::nullopt},
};
}
}
FullConfigSLA::FullConfigSLA(const ConfigPackSLA& config_pack)
: FullConfig{as_boxes(config_pack), {}, get_sla_location_sizes()}
FullConfigSLA::FullConfigSLA(const ConfigPackSLA& config_pack, const Preset::HwPrinterConfig& hw_config)
: FullConfig{as_boxes(config_pack), {}, hw_config}
{}
PartialObjectConfigSLA::PartialObjectConfigSLA(
const SLAObjectSettings& object_settings
const SLAObjectSettings& object_settings,
const Preset::HwPrinterConfig& hw_config
)
: PartialConfig{{object_settings}, get_sla_location_sizes()}
: PartialConfig{{object_settings}, hw_config}
{}
} // namespace Slic3r::Domain

View file

@ -3,6 +3,7 @@
#include <catch2/matchers/catch_matchers_all.hpp>
#include "Slic3r/Domain/Config.hpp"
#include "Slic3r/Domain/TestUtils.hpp"
using namespace Catch;
using namespace Catch::Matchers;
@ -18,7 +19,6 @@ using Slic3r::Domain::BoxRefs;
using Slic3r::Domain::BoxOrBoxesVector;
using Slic3r::Domain::EnumValueDefs;
using Slic3r::Domain::EnumWrapper;
using Slic3r::Domain::ConfigLocationSizes;
using Slic3r::Domain::FDMConfigLocation::Print;
using Slic3r::Domain::FDMConfigLocation::Filament;
@ -37,12 +37,6 @@ const EnumValueDefs test_enum_def{
{ int(TestEnum::Three), "three", "Three" }
};
const ConfigLocationSizes location_sizes{
{Print, std::nullopt},
{Filament, 3},
{Object, std::nullopt},
};
void init(ConfigDefinitions& defs) {
auto def{defs.add("print_config_item_with_object_override", typeid(int))};
def->location = Print;
@ -164,9 +158,12 @@ BoxOrBoxesVector get_input(
struct TestFullConfig : public FullConfig
{
TestFullConfig(
const TestPrintSettings& test_box, const std::vector<TestFilamentSettings>& boxes_with_overrides
)
: FullConfig{get_input(test_box, boxes_with_overrides), {}, location_sizes}
const TestPrintSettings& test_box,
const std::vector<TestFilamentSettings>& boxes_with_overrides) :
FullConfig{
get_input(test_box, boxes_with_overrides),
{},
Slic3r::Test::build_fff_printer_config(3, {})}
{}
};
@ -185,6 +182,8 @@ TEST_CASE("Full config can be created from boxes", "[Config]")
CHECK_THAT(
full_config.keys(),
UnorderedEquals(std::vector<std::string>{
"nozzle_diameter",
"nozzle_high_flow",
"print_config_item_with_object_override",
"print_config_item",
"print_config_item_with_filament_override",
@ -212,9 +211,9 @@ TEST_CASE("Full config enum override works as expected", "[Config]")
struct TestPartialConfig : public PartialConfig
{
TestPartialConfig(
const TestObjectSettings& boxes_with_overrides, const ConfigLocationSizes& base_location_sizes
const TestObjectSettings& boxes_with_overrides
)
: PartialConfig{{std::ref(boxes_with_overrides)}, base_location_sizes}
: PartialConfig{{std::ref(boxes_with_overrides)}, {}}
{}
};
@ -226,7 +225,7 @@ TEST_CASE("Parial config works as expected", "[Config]")
TestObjectSettings object_settings;
object_settings.overrides.set("print_config_item_with_object_override", 12);
const TestPartialConfig partial_config{object_settings, location_sizes};
const TestPartialConfig partial_config{object_settings};
CHECK(partial_config.get<int>("print_config_item_with_object_override") == std::optional{12});
CHECK(partial_config.get<int>("object_config_item") == std::optional{111});

View file

@ -0,0 +1,342 @@
#include "Slic3r/Domain/ConfigBoxesFDM.hpp"
#include "Slic3r/Domain/ConfigDefsFDM.hpp"
#include "Slic3r/Domain/FullConfigFDM.hpp"
#include "Slic3r/Domain/TestUtils.hpp"
#include "Slic3r/Domain/Config.hpp"
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_approx.hpp>
using namespace Slic3r::Domain;
using Slic3r::Test::build_fff_printer_config;
struct FullConfigFDMFixture
{
int extruder_count{3};
ConfigPackFDM config_pack{extruder_count};
std::vector<unsigned> extruder_candidates{0, 2};
Preset::HwPrinterConfig hw_config{build_fff_printer_config(extruder_count, {})};
};
TEST_CASE_METHOD(FullConfigFDMFixture, "Simple no special handling config value", "[FDMConfig]")
{
// Simple in, scalar out.
config_pack.print.items.opt("arc_fitting").set(ArcFittingType::EmitCenter);
FullConfigFDM full_config{config_pack, extruder_candidates, hw_config};
CHECK(full_config.get<ArcFittingType>("arc_fitting") == ArcFittingType::EmitCenter);
}
TEST_CASE_METHOD(FullConfigFDMFixture, "Print config value with override in tool", "[FDMConfig]")
{
// Scalar in print, override in tool => vector as a result.
config_pack.print.items.opt("bottom_solid_layers").set(11);
config_pack.tool.at(2).overrides.set("bottom_solid_layers", 22);
FullConfigFDM full_config{config_pack, extruder_candidates, hw_config};
CHECK(full_config.get<std::vector<int>>("bottom_solid_layers") == std::vector<int>{11, 11, 22});
}
TEST_CASE_METHOD(
FullConfigFDMFixture,
"Print config value with override in just Object",
"[FDMConfig]")
{
// Scalar, but can be overriden.
config_pack.print.items.opt("brim_width").set(4.2);
FullConfigFDM full_config{config_pack, extruder_candidates, hw_config};
CHECK(full_config.get<double>("brim_width") == 4.2);
ObjectSettings object_settings;
object_settings.overrides.set("brim_width", 3.0);
auto partial_config{std::make_shared<
PartialObjectConfigFDM>(object_settings, hw_config)};
ConfigView config_view{std::make_shared<FullConfigFDM>(full_config), {partial_config}};
config_view.finalize();
CHECK(config_view.get<double>("brim_width") == 3.0);
}
TEST_CASE_METHOD(FullConfigFDMFixture, "Tool parity is ensured", "[FDMConfig]")
{
config_pack.printer.items.opt("extruder_offset").set(std::vector<Vec2d>{Vec2d{42.0, 42.0}});
FullConfigFDM full_config{config_pack, extruder_candidates, hw_config};
CHECK(full_config.get<std::vector<Vec2d>>("extruder_offset").size() == 3);
}
TEST_CASE_METHOD(FullConfigFDMFixture, "Compatibility rule application - average", "[FDMConfig]")
{
// Scalar in print, override in tool with compatibility rule => scalar as a result.
// Extruders 0, 2 are used.
// The compatibility rule is 'average'.
config_pack.print.items.opt("brim_separation").set(10.0);
// Extruder 1 is also overriden, but as unused, it is ignored.
config_pack.tool.at(1).overrides.set("brim_separation", 1000.0);
config_pack.tool.at(2).overrides.set("brim_separation", 20.0);
auto full_config{std::make_shared<const FullConfigFDM>(config_pack, extruder_candidates, hw_config)};
ConfigView view{full_config, {}};
view.finalize();
CHECK(view.get<double>("brim_separation") == Catch::Approx(15.0));
}
TEST_CASE_METHOD(FullConfigFDMFixture, "Compatibility rule application - ignore overrides", "[FDMConfig]")
{
// Scalar in print, override in tool with compatibility rule => scalar as a result.
// Extruders 0, 2 are used.
// The value is the same for both used tool, no rule is applied.
config_pack.print.items.opt("seam_position").set(SeamPosition::spRandom);
config_pack.tool.at(0).overrides.set("seam_position", SeamPosition::spNearest);
config_pack.tool.at(2).overrides.set("seam_position", SeamPosition::spNearest);
auto full_config{std::make_shared<const FullConfigFDM>(config_pack, extruder_candidates, hw_config)};
ConfigView view{full_config, {}};
view.finalize();
CHECK(view.get<SeamPosition>("seam_position") == SeamPosition::spNearest);
// There is a conflict and the resolution is to ignore overrides.
config_pack.print.items.opt("seam_position").set(SeamPosition::spRandom);
config_pack.tool.at(0).overrides.set("seam_position", SeamPosition::spRear);
config_pack.tool.at(2).overrides.set("seam_position", SeamPosition::spAligned);
full_config = std::make_shared<const FullConfigFDM>(config_pack, extruder_candidates, hw_config);
view = ConfigView{full_config, {}};
view.finalize();
CHECK(view.get<SeamPosition>("seam_position") == SeamPosition::spRandom);
}
TEST_CASE_METHOD(
FullConfigFDMFixture,
"FDM config spreads the values over slot_count for the mmu use case",
"[FDMConfig]")
{
// Tool 0: 8 materials
// Tool 1: 1 material
// Tool 2: 6 materials
// Total 15 materials.
hw_config.feeders = {
{Preset::Address{0}, Preset::HwFeederConfig{.slot_count = 4}},
{Preset::Address{0, 3}, Preset::HwFeederConfig{.slot_count = 5}},
{Preset::Address{2}, Preset::HwFeederConfig{.slot_count = 6}},
};
config_pack.tool.at(0).overrides.set("perimeter_speed", 42.0);
config_pack.tool.at(1).overrides.set("perimeter_speed", 33.0);
config_pack.tool.at(2).overrides.set("perimeter_speed", 66.0);
config_pack.filament.resize(hw_config.material_slot_count());
config_pack.printer.items.opt("extruder_offset").set(std::vector{Vec2d{0, 0}});
FullConfigFDM full_config{config_pack, extruder_candidates, hw_config};
const auto nozzle_diameters{full_config.get<std::vector<double>>("nozzle_diameter")};
REQUIRE(nozzle_diameters.size() == hw_config.material_slot_count());
CHECK(nozzle_diameters[14] == Catch::Approx(0.4));
const auto perimeter_speeds{full_config.get<std::vector<double>>("perimeter_speed")};
REQUIRE(perimeter_speeds.size() == hw_config.material_slot_count());
CHECK(perimeter_speeds[7] == Catch::Approx(42.0));
CHECK(perimeter_speeds[8] == Catch::Approx(33.0));
CHECK(perimeter_speeds[14] == Catch::Approx(66.0));
}
TEST_CASE_METHOD(
FullConfigFDMFixture,
"FloatOrPercentage over nozzle diameter is resolved",
"[FDMConfig]")
{
config_pack.print.items.opt("automatic_infill_combination_max_layer_height")
.set(FloatOrPercentage{Percentage{50}});
auto full_config{std::make_shared<const FullConfigFDM>(config_pack, extruder_candidates, hw_config)};
ConfigView view{full_config, {}};
view.finalize();
const auto result{
view.get<std::vector<FloatOrPercentage>>("automatic_infill_combination_max_layer_height")};
for (FloatOrPercentage value : result) {
REQUIRE(!value.is_percentage());
CHECK(value.float_value() == Catch::Approx(0.2));
}
}
TEST_CASE_METHOD(
FullConfigFDMFixture,
"FloatOrPercentage over another config value is resolved, including overrides",
"[FDMConfig]")
{
config_pack.print.items.opt("external_perimeter_speed").set(FloatOrPercentage{Percentage{50}});
config_pack.tool.at(0).overrides.set("external_perimeter_speed", FloatOrPercentage{42.0});
config_pack.tool.at(2)
.overrides.set("external_perimeter_speed", FloatOrPercentage{Percentage{25}});
config_pack.print.items.opt("perimeter_speed").set(100.0);
config_pack.tool.at(0).overrides.set("perimeter_speed", 1000.0);
config_pack.tool.at(1).overrides.set("perimeter_speed", 10000.0);
auto full_config{std::make_shared<const FullConfigFDM>(config_pack, extruder_candidates, hw_config)};
ConfigView view{full_config, {}};
view.finalize();
const auto result{view.get<std::vector<FloatOrPercentage>>("external_perimeter_speed")};
for (const FloatOrPercentage& value : result) {
REQUIRE(!value.is_percentage());
}
REQUIRE(result.size() == 3);
CHECK(result[0].float_value() == Catch::Approx(42.0)); // Just the value.
CHECK(result[1].float_value() == Catch::Approx(5000.0)); // 50% out of 100000.0
CHECK(result[2].float_value() == Catch::Approx(25.0)); // 25% out of 100.0
}
TEST_CASE_METHOD(
FullConfigFDMFixture,
"Print view respect partial config overrides for items with compatibility rule",
"[FDMConfig]")
{
// Tools 0 and 2 are used.
config_pack.print.items.opt("brim_separation").set(10.0);
config_pack.tool.at(2).overrides.set("brim_separation", 20.0);
auto full_config{std::make_shared<const FullConfigFDM>(config_pack, extruder_candidates, hw_config)};
ConfigView view{full_config, {}};
view.finalize();
auto result{view.get<double>("brim_separation")};
CHECK(result == Catch::Approx(15.0)); // Average
ObjectSettings object_settings;
object_settings.overrides.set("brim_separation", 30.0);
auto partial_config{std::make_shared<PartialObjectConfigFDM>(object_settings, hw_config)};
view = ConfigView{full_config, {partial_config}};
view.finalize();
result = view.get<double>("brim_separation");
CHECK(result == Catch::Approx(30.0)); // The overriden value.
}
TEST_CASE_METHOD(
FullConfigFDMFixture,
"Print view respect partial config overrides and resolves float or percentage",
"[FDMConfig]")
{
// Tools 0 and 2 are used.
config_pack.tool.at(0).overrides.set("perimeter_speed", 100.0);
config_pack.print.items.opt("perimeter_speed").set(1000.0);
config_pack.print.items.opt("external_perimeter_speed").set(FloatOrPercentage{Percentage{50}});
config_pack.tool.at(2).overrides.set("external_perimeter_speed", FloatOrPercentage{Percentage{25}});
auto full_config{std::make_shared<const FullConfigFDM>(config_pack, extruder_candidates, hw_config)};
ConfigView view{full_config, {}};
view.finalize();
auto result{view.get<std::vector<FloatOrPercentage>>("external_perimeter_speed")};
REQUIRE(result.size() == 3);
CHECK(!result[0].is_percentage());
CHECK(!result[2].is_percentage());
CHECK(result[0].float_value() == Catch::Approx(50.0));
CHECK(result[2].float_value() == Catch::Approx(250.0));
ObjectSettings object_settings;
object_settings.overrides.set("external_perimeter_speed", FloatOrPercentage{Percentage{75}});
auto partial_config{std::make_shared<PartialObjectConfigFDM>(object_settings, hw_config)};
view = ConfigView{full_config, {partial_config}};
view.finalize();
result = view.get<std::vector<FloatOrPercentage>>("external_perimeter_speed");
CHECK(!result.at(0).is_percentage());
CHECK(!result.at(2).is_percentage());
CHECK(result.at(0).float_value() == Catch::Approx(75));
CHECK(result.at(2).float_value() == Catch::Approx(750));
}
TEST_CASE_METHOD(
FullConfigFDMFixture,
"Check that all float or percentage values are resolved",
"[FDMConfig]")
{
MutBoxOrBoxesVector boxes{as_mut_boxes(config_pack)};
for (auto& box_or_boxes : boxes) {
std::visit(
overloaded{
[](const MutBoxRef& box)
{
for (ConfigItem& item : box.get().items.all_items()) {
if (item.holds_alternative<FloatOrPercentage>()) {
item.set(FloatOrPercentage{Percentage{50}});
}
}
},
[](const MutBoxRefs& boxes)
{
for (const MutBoxRef& box : boxes) {
for (ConfigItem& item : box.get().items.all_items()) {
if (item.holds_alternative<FloatOrPercentage>()) {
item.set(FloatOrPercentage{Percentage{50}});
}
}
}
},
},
box_or_boxes);
}
auto full_config{std::make_shared<const FullConfigFDM>(config_pack, extruder_candidates, hw_config)};
ConfigView view{full_config, {}};
for (const auto& [name, config_value] : view.values()) {
INFO(name);
if (config_value.holds_alternative<FloatOrPercentage>()) {
REQUIRE(!config_value.get<FloatOrPercentage>().is_percentage());
}
if (config_value.holds_alternative<std::vector<FloatOrPercentage>>()) {
for (const FloatOrPercentage& value :
config_value.get<std::vector<FloatOrPercentage>>())
{
REQUIRE(!value.is_percentage());
}
}
}
}
TEST_CASE_METHOD(
FullConfigFDMFixture,
"Parameter expansion works as expected",
"[FDMConfig]")
{
config_pack.tool.at(0).overrides.set("external_perimeter_speed", FloatOrPercentage{100});
config_pack.print.items.opt("first_layer_speed").set(FloatOrPercentage{Percentage{75}});
config_pack.tool.at(0).overrides.set("first_layer_speed", FloatOrPercentage{Percentage{50}});
config_pack.print.items.opt("perimeter_speed").set(1000.0);
config_pack.print.items.opt("external_perimeter_speed").set(FloatOrPercentage{Percentage{100}});
auto full_config{std::make_shared<const FullConfigFDM>(config_pack, extruder_candidates, hw_config)};
ConfigView view{full_config, {}};
view.finalize();
auto result{view.get<std::vector<FloatOrPercentage>>("first_layer_external_perimeter_speed")};
REQUIRE(result.size() == 3);
REQUIRE(!result[0].is_percentage());
REQUIRE(!result[1].is_percentage());
CHECK(result[0].float_value() == Catch::Approx(50));
CHECK(result[1].float_value() == Catch::Approx(750));
config_pack.tool.at(0).overrides.set("first_layer_external_perimeter_speed", FloatOrPercentage{Percentage{25}});
config_pack.print.items.opt("first_layer_external_perimeter_speed").set(FloatOrPercentage{Percentage{10}});
full_config = std::make_shared<const FullConfigFDM>(config_pack, extruder_candidates, hw_config);
view = ConfigView{full_config, {}};
view.finalize();
result = view.get<std::vector<FloatOrPercentage>>("first_layer_external_perimeter_speed");
REQUIRE(result.size() == 3);
REQUIRE(!result[0].is_percentage());
REQUIRE(!result[1].is_percentage());
CHECK(result[0].float_value() == Catch::Approx(25));
CHECK(result[1].float_value() == Catch::Approx(100));
}

View file

@ -1,25 +1,14 @@
#include "Slic3r/Domain/Preset/HwConfig.hpp"
#include "Slic3r/Domain/TestUtils.hpp"
#include <catch2/catch_test_macros.hpp>
using namespace Slic3r::Domain;
using namespace Slic3r::Domain::Preset;
using Addresses = std::vector<Address>;
using Slic3r::Test::build_fff_printer_config;
HwPrinterConfig build_fff_printer_config(uint8_t tool_count, HwFeederConfigs feeders)
{
HwToolConfigs tools{tool_count, HwToolConfig{}};
HwPrinterConfig printer_config = {
.printer_id = "printer",
.technology = PrinterTechnology::FFF,
.tool_count = tool_count,
.tools = std::move(tools),
.feeders = std::move(feeders)
};
return printer_config;
}
Addresses iterate(const HwPrinterConfig& config)
{
Addresses visited_addresses;

View file

@ -0,0 +1,21 @@
#include "Slic3r/Domain/TestUtils.hpp"
namespace Slic3r::Test {
using namespace Slic3r::Domain::Preset;
HwPrinterConfig build_fff_printer_config(uint8_t tool_count, HwFeederConfigs feeders)
{
FeatureValueMap tool_features;
tool_features["nozzle_diameter"] = 0.4;
HwToolConfigs tools{tool_count, HwToolConfig{.features = tool_features}};
HwPrinterConfig printer_config = {.printer_id = "printer",
.technology = Domain::PrinterTechnology::FFF,
.tool_count = tool_count,
.tools = std::move(tools),
.feeders = std::move(feeders)};
return printer_config;
}
} // namespace Slic3r::Test

View file

@ -0,0 +1,10 @@
#pragma once
#include "Slic3r/Domain/Preset/HwConfig.hpp"
namespace Slic3r::Test {
Domain::Preset::HwPrinterConfig build_fff_printer_config(uint8_t tool_count,
Domain::Preset::HwFeederConfigs feeders);
} // namespace Slic3r::Test

View file

@ -110,7 +110,7 @@ void ExplanationContainer::update_explanation(const Biz::PrintToolItem& print_to
const ImColor text_color = m_theme->color_imgui(Platform::Color::Text);
const Domain::CompatibilityRule compatibility_rule =
print_tool_item.print_item->compatibility_rule();
if (print_tool_item.print_item->def().require_compatibility_rule
if (print_tool_item.print_item->def().compatibility_rule != Domain::CompatibilityRule::Undefined
&& print_tool_item.value.second)
{
if (compatibility_rule == Domain::CompatibilityRule::IgnoreOverrides) {

View file

@ -89,7 +89,7 @@ void PrintToolRowButton::update_data(const Biz::PrintToolItem* print_tool_item)
bool show_preview = false;
std::optional<Domain::ConfigValue> value;
if (print_tool_item->print_item->def().require_compatibility_rule) {
if (print_tool_item->print_item->def().compatibility_rule != Domain::CompatibilityRule::Undefined) {
show_preview = true;
} else if (print_tool_item->shared_context.extruder_candidates.empty()) {
// Extruder candidates are empty, just compare all extruder values

View file

@ -6,6 +6,7 @@
#include "Slic3r/Biz/Algorithms/BoundingBox.hpp"
#include "Slic3r/Biz/Algorithms/Point.hpp"
#include "Slic3r/Biz/Algorithms/ExPolygon.hpp"
#include "Slic3r/Domain/ConfigDefsFDM.hpp"
#include "Slic3r/Biz/Platform/JobManager/JobManager.hpp"
#include "Slic3r/Biz/Platform/PlatformServices.hpp"

View file

@ -510,6 +510,17 @@ static void handle_legacy_project_loaded(
config.erase("support_material_auto");
}
if (auto* first_layer_infill_speed{config.option<
Slic3rLegacy::ConfigOptionFloatOrPercent>("first_layer_infill_speed", false)};
first_layer_infill_speed != nullptr)
{
auto* first_layer_solid_infill_speed{config.option<
Slic3rLegacy::ConfigOptionFloatOrPercent>("first_layer_solid_infill_speed", true)};
first_layer_solid_infill_speed->percent = first_layer_infill_speed->percent;
first_layer_solid_infill_speed->value = first_layer_infill_speed->value;
first_layer_infill_speed->percent = false;
first_layer_infill_speed->value = 0;
}
}
}

View file

@ -614,17 +614,16 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("avoid_crossing_perimeters_max_detour", coFloatOrPercent);
def = this->add("avoid_crossing_perimeters_max_detour", coFloat);
def->label = L("Avoid crossing perimeters - Max detour length");
def->category = L("Layers and Perimeters");
def->tooltip = L("The maximum detour length for avoid crossing perimeters. "
"If the detour is longer than this value, avoid crossing perimeters is not applied for this travel path. "
"Detour length could be specified either as an absolute value or as percentage (for example 50%) of a direct travel path.");
def->sidetext = L("mm or % (zero to disable)");
"If the detour is longer than this value, avoid crossing perimeters is not applied for this travel path.");
def->sidetext = L("mm");
def->min = 0;
def->max_literal = 1000;
def->mode = comExpert;
def->set_default_value(new ConfigOptionFloatOrPercent(0., false));
def->set_default_value(new ConfigOptionFloat(0.));
def = this->add("bed_temperature", coInts);
def->label = L("Other layers");
@ -1757,6 +1756,14 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(0, false));
def = this->add("first_layer_solid_infill_speed", coFloatOrPercent);
def->label = L("First layer solid infill speed");
def->tooltip = "first_layer_solid_infill_speed introduced in slicer 3.0";
def->sidetext = L("mm/s or %");
def->min = 0;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(0, false));
def = this->add("first_layer_speed_over_raft", coFloatOrPercent);
def->label = L("Speed of object first layer over raft interface");
def->tooltip = L("If expressed as absolute value in mm/s, this speed will be applied to all the print moves "
@ -5262,6 +5269,9 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
// We map "1" to "everywhere" here, handle_legacy_project_loaded() downgrades it to
// "enforcers_only" when needed.
value = value == "1" ? "everywhere" : "none";
} else if (opt_key == "avoid_crossing_perimeters_max_detour" && value.find('%') != std::string::npos) {
// In PrusaSlicer 3.0.0 avoid crossing perimeters max detour is just absolute.
value = "0";
}
// In PrusaSlicer 2.3.0-alpha0 the "monotonous" infill was introduced, which was later renamed to "monotonic".

View file

@ -953,7 +953,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
((ConfigOptionBool, automatic_extrusion_widths))
((ConfigOptionBool, avoid_crossing_curled_overhangs))
((ConfigOptionBool, avoid_crossing_perimeters))
((ConfigOptionFloatOrPercent, avoid_crossing_perimeters_max_detour))
((ConfigOptionFloat, avoid_crossing_perimeters_max_detour))
((ConfigOptionPoints, bed_shape))
((ConfigOptionInts, bed_temperature))
((ConfigOptionFloat, bridge_acceleration))
@ -989,6 +989,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
((ConfigOptionFloatOrPercent, first_layer_height))
((ConfigOptionFloatOrPercent, first_layer_speed))
((ConfigOptionFloatOrPercent, first_layer_infill_speed))
((ConfigOptionFloatOrPercent, first_layer_solid_infill_speed))
((ConfigOptionInts, first_layer_temperature))
((ConfigOptionIntsNullable, idle_temperature))
((ConfigOptionInts, full_fan_speed_layer))

View file

@ -39,12 +39,14 @@ ExportNameData parse_fdm_export_name(
ASSERT(bed_instance != nullptr);
ExportNameData result {Technology::Fdm, project_name, resolve_preferred_extension(output_filename_format)};
Domain::FullConfigFDM full_config{
auto full_config{std::make_shared<Domain::FullConfigFDM>(
fdm_config,
bed_instance->extruder_candidates,
project_interactor.preset_interactor().current_printer_config()
};
Biz::Parser::IO::Config io_config = Biz::Parser::IO::get_parser_config(full_config);
)};
Domain::ConfigView view{full_config, {}};
view.finalize();
Biz::Parser::IO::Config io_config = Biz::Parser::IO::get_parser_config(view);
Biz::Parser::PlaceholderParser parser{io_config};
const std::optional<Biz::FDMResultRef> fdm_result_opt{project_interactor.fdm_result_cache().get_result(project_interactor.selected_bed_slicing_id())};
if (!fdm_result_opt) {
@ -152,8 +154,14 @@ ExportNameData parse_sla_export_name(
)
{
ExportNameData result {Technology::Sla, project_name, resolve_preferred_extension(output_filename_format)};
Domain::FullConfigSLA full_config{sla_config};
Biz::Parser::IO::Config io_config = Biz::Parser::IO::get_parser_config(full_config);
auto full_config{std::make_shared<Domain::FullConfigSLA>(
sla_config, project_interactor.preset_interactor().current_printer_config()
)};
Domain::ConfigView view{full_config, {}};
view.finalize();
Biz::Parser::IO::Config io_config = Biz::Parser::IO::get_parser_config(view);
Biz::Parser::PlaceholderParser parser{io_config};
const Biz::SLAResultOptRef sla_result_opt{project_interactor.sla_result_cache().get_result(project_interactor.selected_bed_slicing_id())};
if (!sla_result_opt) {

View file

@ -2,6 +2,7 @@
#include "Slic3r/Biz/ResultExport/SLA/Zipper.hpp"
#include "Slic3r/Domain/ConfigBoxesSLA.hpp"
#include "Slic3r/Domain/ConfigDefsSLA.hpp"
#include "Slic3r/Domain/FullConfigSLA.hpp"
#include "Slic3r/Domain/Image.hpp"
#include "Slic3r/Biz/Algorithms/ImageUtils.hpp"
@ -69,7 +70,7 @@ const std::vector<std::string> count_opts{
"tilt_up_cycles"
};
std::string tilt_options_to_json(const Domain::FullConfigSLA& cfg, const ConfMap& iniconf)
std::string tilt_options_to_json(const Domain::ConfigView& cfg, const ConfMap& iniconf)
{
json below_node;
json above_node;
@ -139,7 +140,7 @@ static std::string serialize(const double value)
return ss.str();
}
void fill_iniconf(ConfMap &m, const Domain::FullConfigSLA &cfg, const Domain::SLA::PrintStatistics &stats) {
void fill_iniconf(ConfMap &m, const Domain::ConfigView &cfg, const Domain::SLA::PrintStatistics &stats) {
using Domain::SLAMaterialSpeed;
using Domain::SLAMaterialSpeed::slamsSlow;
using Domain::SLAMaterialSpeed::slamsFast;
@ -208,10 +209,10 @@ void store_sl1(const std::string& file_path, const Slicing::SLAResultData& data)
const auto& stats = *data.print_statistics;
const Biz::Slicing::SerializedConfig& serialized_config{data.serialized_config};
const Domain::FullConfigSLA& full_config{data.full_config};
const Domain::ConfigView& print_config{data.config};
ConfMap iniconf;
fill_iniconf(iniconf, full_config, stats);
fill_iniconf(iniconf, print_config, stats);
iniconf["jobDir"] = project;
@ -219,7 +220,7 @@ void store_sl1(const std::string& file_path, const Slicing::SLAResultData& data)
zipper.add_entry("config.ini");
zipper << to_ini(iniconf);
zipper.add_entry("config.json");
zipper << tilt_options_to_json(full_config, iniconf);
zipper << tilt_options_to_json(print_config, iniconf);
zipper.add_entry("prusaslicer.ini");
zipper << serialized_config.ini;

View file

@ -129,7 +129,6 @@ using Slic3r::Domain::BoxRefs;
using Slic3r::Domain::BoxOrBoxesVector;
using Slic3r::Domain::EnumValueDefs;
using Slic3r::Domain::EnumWrapper;
using Slic3r::Domain::ConfigLocationSizes;
using Slic3r::Domain::FDMConfigLocation::Print;
using Slic3r::Domain::FDMConfigLocation::Filament;
@ -147,11 +146,6 @@ const EnumValueDefs test_enum_def{
{ int(TestEnum::Three), "three", "Three" }
};
const ConfigLocationSizes location_sizes{
{Print, std::nullopt},
{Filament, 3}
};
void init(ConfigDefinitions& defs) {
auto def{defs.add("print_config_item", typeid(int))};
def->category = ConfigItemDef::Category::Hidden;

View file

@ -251,6 +251,7 @@ const std::string model_file{"3D/3dmodel.model"};
const std::map<std::string, std::vector<std::string>> fdm_whitelist{
{config_file, {
"; first_layer_infill_speed",
"; compatible_printers_condition_cummulative",
"; default_filament_profile",
"; default_print_profile",

View file

@ -1,6 +1,8 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_approx.hpp>
#include "Slic3r/Biz/Config/ConfigLoad.hpp"
#include "Slic3r/Domain/ConfigDefsFDM.hpp"
#include "Slic3r/Domain/ConfigDefsSLA.hpp"
#include <nlohmann/json.hpp>
using nlohmann::ordered_json;

View file

@ -64,10 +64,7 @@ struct TestConfig : public Domain::ConfigPackFDM
Biz::Parser::IO::Config get_parser_config() const
{
Domain::FullConfigFDMPtr config{
*ASSERT_VAL(prepare_slicing_input(*this, {}, hw_config))
};
return Biz::Parser::IO::get_parser_config(*config);
return Biz::Parser::IO::get_parser_config(get_view());
};
Domain::FullConfigFDM get_full_config() const

View file

@ -49,13 +49,14 @@ SCENARIO("Perimeter nesting", "[Perimeters]")
auto test = [&](const TestData &data, const TestConfig& config) {
const auto full_config{std::make_shared<const FullConfigFDM>(config.get_full_config())};
Domain::PartialObjectConfigFDM object_config{ObjectSettings{}, full_config->hw_config().material_slot_count()};
Domain::PartialVolumeConfigFDM volume_config{VolumeSettings{}, full_config->hw_config().material_slot_count()};
const PrintRegionConfigView region_config_view{
Domain::PartialObjectConfigFDM object_config{ObjectSettings{}, full_config->hw_config()};
Domain::PartialVolumeConfigFDM volume_config{VolumeSettings{}, full_config->hw_config()};
PrintRegionConfigView region_config_view{
full_config,
std::make_shared<const Domain::PartialObjectConfigFDM>(std::move(object_config)),
{std::make_shared<const Domain::PartialVolumeConfigFDM>(std::move(volume_config))}
};
region_config_view.finalize();
SurfaceCollection slices;
slices.append(data.expolygons, stInternal);

View file

@ -45,17 +45,21 @@ PrintRegionConfigView get_region_config_view(const ObjectSettings& object_settin
*prepare_slicing_input(Domain::ConfigPackFDM{}, {}, Test::create_dummy_hw_config())
};
return {
PrintRegionConfigView result{
full_config,
*prepare_slicing_object_input(
object_settings,
full_config->hw_config(),
full_config->hw_config().material_slot_count()
),
{*prepare_slicing_volume_input(
VolumeSettings{},
full_config->hw_config(),
full_config->hw_config().material_slot_count()
)}
};
result.finalize();
return result;
}
} // namespace
@ -75,7 +79,7 @@ TEST_CASE("Arachne - Closed ExtrusionLine", "[ArachneClosedExtrusionLine]") {
coord_t spacing = 407079;
coord_t inset_count = 5;
Arachne::WallToolPaths wallToolPaths(polygons, spacing, spacing, inset_count, 0, 0.2, get_region_config_view({}));
Arachne::WallToolPaths wallToolPaths(polygons, spacing, spacing, inset_count, 0, 0.2, get_region_config_view({}), 0);
wallToolPaths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wallToolPaths.getToolPaths();
@ -108,7 +112,7 @@ TEST_CASE("Arachne - Missing perimeter - #8472", "[ArachneMissingPerimeter8472]"
ObjectSettings object_settings;
object_settings.overrides.set("wall_distribution_count", 3);
Arachne::WallToolPaths wallToolPaths(polygons, spacing, spacing, inset_count, 0, 0.2, get_region_config_view(object_settings));
Arachne::WallToolPaths wallToolPaths(polygons, spacing, spacing, inset_count, 0, 0.2, get_region_config_view(object_settings), 0);
wallToolPaths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wallToolPaths.getToolPaths();
@ -149,7 +153,7 @@ TEST_CASE("Arachne - #8593 - Missing a part of the extrusion", "[ArachneMissingP
poly.rotate(angle);
Polygons polygons = {poly};
Arachne::WallToolPaths wall_tool_paths(polygons, spacing, spacing, inset_count, 0, 0.2, get_region_config_view(object_settings));
Arachne::WallToolPaths wall_tool_paths(polygons, spacing, spacing, inset_count, 0, 0.2, get_region_config_view(object_settings), 0);
wall_tool_paths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wall_tool_paths.getToolPaths();
@ -184,7 +188,7 @@ TEST_CASE("Arachne - #8573 - A gap in the perimeter - 1", "[ArachneGapInPerimete
// print_object_config.wall_transition_angle = ConfigOptionFloat(20.);
Arachne::WallToolPaths wallToolPaths(polygons, spacing, spacing, inset_count, 0, 0.2, get_region_config_view({}));
Arachne::WallToolPaths wallToolPaths(polygons, spacing, spacing, inset_count, 0, 0.2, get_region_config_view({}), 0);
wallToolPaths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wallToolPaths.getToolPaths();
@ -226,7 +230,7 @@ TEST_CASE("Arachne - #8444 - A gap in the perimeter - 2", "[ArachneGapInPerimete
// print_object_config.wall_transition_angle = ConfigOptionFloat(20.);
Arachne::WallToolPaths wallToolPaths(polygons, spacing, spacing, inset_count, 0, 0.4, get_region_config_view({}));
Arachne::WallToolPaths wallToolPaths(polygons, spacing, spacing, inset_count, 0, 0.4, get_region_config_view({}), 0);
wallToolPaths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wallToolPaths.getToolPaths();
@ -269,7 +273,7 @@ TEST_CASE("Arachne - #8528 - A hole when number of perimeters is changing", "[Ar
// Changing min_bead_width to 0.66 seems that resolve this issue, at least in this case.
object_settings.overrides.set("min_bead_width", FloatOrPercentage{0.66});
Arachne::WallToolPaths wallToolPaths(polygons, spacing, spacing, inset_count, 0, 0.4, get_region_config_view(object_settings));
Arachne::WallToolPaths wallToolPaths(polygons, spacing, spacing, inset_count, 0, 0.4, get_region_config_view(object_settings), 0);
wallToolPaths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wallToolPaths.getToolPaths();
@ -338,7 +342,7 @@ TEST_CASE("Arachne - #8555 - Inconsistent single perimeter", "[ArachneInconsiste
for (size_t poly_idx = 0; poly_idx < polygons.size(); ++poly_idx) {
Polygons input_polygons{polygons[poly_idx]};
Arachne::WallToolPaths wallToolPaths(input_polygons, spacing, spacing, inset_count, 0, 0.15, get_region_config_view({}));
Arachne::WallToolPaths wallToolPaths(input_polygons, spacing, spacing, inset_count, 0, 0.15, get_region_config_view({}), 0);
wallToolPaths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wallToolPaths.getToolPaths();
@ -396,7 +400,7 @@ TEST_CASE("Arachne - #8633 - Shorter open perimeter", "[ArachneShorterOpenPerime
for (size_t poly_idx = 0; poly_idx < polygons.size(); ++poly_idx) {
Polygons input_polygons{polygons[poly_idx]};
Arachne::WallToolPaths wallToolPaths(input_polygons, spacing, spacing, inset_count, 0, 0.15, get_region_config_view(object_settings));
Arachne::WallToolPaths wallToolPaths(input_polygons, spacing, spacing, inset_count, 0, 0.15, get_region_config_view(object_settings), 0);
wallToolPaths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wallToolPaths.getToolPaths();
@ -430,7 +434,7 @@ TEST_CASE("Arachne - #8597 - removeSmallAreas", "[ArachneRemoveSmallAreas8597]")
coord_t spacing = 407079;
coord_t inset_count = 2;
Arachne::WallToolPaths wallToolPaths(polygons, spacing, spacing, inset_count, 0, 0.2, get_region_config_view({}));
Arachne::WallToolPaths wallToolPaths(polygons, spacing, spacing, inset_count, 0, 0.2, get_region_config_view({}), 0);
wallToolPaths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wallToolPaths.getToolPaths();
@ -467,7 +471,7 @@ TEST_CASE("Arachne - Missing infill", "[ArachneMissingInfill]") {
coord_t spacing = 357079;
coord_t inset_count = 2;
Arachne::WallToolPaths wallToolPaths(polygons, spacing, spacing, inset_count, 0, 0.2, get_region_config_view({}));
Arachne::WallToolPaths wallToolPaths(polygons, spacing, spacing, inset_count, 0, 0.2, get_region_config_view({}), 0);
wallToolPaths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wallToolPaths.getToolPaths();
@ -496,7 +500,7 @@ TEST_CASE("Arachne - #8849 - Missing part of model", "[ArachneMissingPart8849]")
coord_t perimeter_spacing = 757079;
coord_t inset_count = 2;
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.32, get_region_config_view({}));
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.32, get_region_config_view({}), 0);
wall_tool_paths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wall_tool_paths.getToolPaths();
@ -537,7 +541,7 @@ TEST_CASE("Arachne - #8446 - Degenerated Voronoi diagram - Linear edges", "[Arac
coord_t perimeter_spacing = 407079;
coord_t inset_count = 1;
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, get_region_config_view({}));
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, get_region_config_view({}), 0);
wall_tool_paths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wall_tool_paths.getToolPaths();
@ -612,7 +616,7 @@ TEST_CASE("Arachne - #8846 - Degenerated Voronoi diagram - One Parabola", "[Arac
coord_t perimeter_spacing = 607079;
coord_t inset_count = 1;
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, get_region_config_view({}));
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, get_region_config_view({}), 0);
wall_tool_paths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wall_tool_paths.getToolPaths();
@ -660,7 +664,7 @@ TEST_CASE("Arachne - #9357 - Degenerated Voronoi diagram - Two parabolas", "[Ara
coord_t perimeter_spacing = 407079;
coord_t inset_count = 1;
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, get_region_config_view({}));
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, get_region_config_view({}), 0);
wall_tool_paths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wall_tool_paths.getToolPaths();
@ -700,7 +704,7 @@ TEST_CASE("Arachne - #8846 - Degenerated Voronoi diagram - Voronoi edges interse
coord_t perimeter_spacing = 407079;
coord_t inset_count = 1;
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.32, get_region_config_view({}));
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.32, get_region_config_view({}), 0);
wall_tool_paths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wall_tool_paths.getToolPaths();
@ -762,7 +766,7 @@ TEST_CASE("Arachne - #10034 - Degenerated Voronoi diagram - That wasn't fixed by
coord_t perimeter_spacing = 407079;
coord_t inset_count = 1;
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, get_region_config_view({}));
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, get_region_config_view({}), 0);
wall_tool_paths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wall_tool_paths.getToolPaths();
@ -784,7 +788,7 @@ TEST_CASE("Arachne - SPE-1837 - No perimeters generated", "[ArachneNoPerimetersG
coord_t perimeter_spacing = 700000;
coord_t inset_count = 1;
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, get_region_config_view({}));
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, get_region_config_view({}), 0);
wall_tool_paths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wall_tool_paths.getToolPaths();
@ -820,7 +824,7 @@ TEST_CASE("Arachne - SPE-2298 - Missing twin edge", "[ArachneMissingTwinEdgeSPE2
coord_t perimeter_spacing = 407079;
coord_t inset_count = 1;
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, get_region_config_view({}));
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, get_region_config_view({}), 0);
wall_tool_paths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wall_tool_paths.getToolPaths();
@ -867,7 +871,7 @@ TEST_CASE("Arachne - SPE-2298 - Missing twin edge - 2", "[ArachneMissingTwinEdge
coord_t perimeter_spacing = 407079;
coord_t inset_count = 1;
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, get_region_config_view({}));
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, get_region_config_view({}), 0);
wall_tool_paths.generate();
std::vector<Arachne::VariableWidthLines> perimeters = wall_tool_paths.getToolPaths();
@ -910,7 +914,7 @@ TEST_CASE("Arachne - SPE-2496 - Negative extrusion width", "[Arachne_Negative_Ex
ObjectSettings object_settings;
object_settings.overrides.set("min_bead_width", FloatOrPercentage{0.1});
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, get_region_config_view(object_settings));
Arachne::WallToolPaths wall_tool_paths(polygons, ext_perimeter_spacing, perimeter_spacing, inset_count, 0, 0.2, get_region_config_view(object_settings), 0);
wall_tool_paths.generate();
Arachne::Perimeters perimeters = wall_tool_paths.getToolPaths();