mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-03 00:02:14 +00:00
Merge branch 'main' into dev/update-bbs-network
This commit is contained in:
@@ -550,7 +550,7 @@ set(OCCT_LIBS
|
||||
TKernel
|
||||
)
|
||||
|
||||
|
||||
find_package(libnoise REQUIRED)
|
||||
target_link_libraries(libslic3r
|
||||
libnest2d
|
||||
admesh
|
||||
@@ -576,6 +576,7 @@ target_link_libraries(libslic3r
|
||||
JPEG::JPEG
|
||||
qoi
|
||||
opencv_world
|
||||
noise::noise
|
||||
)
|
||||
|
||||
if(NOT WIN32)
|
||||
|
||||
@@ -839,8 +839,9 @@ int ConfigBase::load_from_json(const std::string &file, ConfigSubstitutionContex
|
||||
}
|
||||
else if (!load_inherits_to_config && boost::iequals(it.key(), BBL_JSON_KEY_INHERITS)) {
|
||||
key_values.emplace(BBL_JSON_KEY_INHERITS, it.value());
|
||||
}
|
||||
else {
|
||||
} else if (boost::iequals(it.key(), ORCA_JSON_KEY_RENAMED_FROM)) {
|
||||
key_values.emplace(ORCA_JSON_KEY_RENAMED_FROM, it.value());
|
||||
} else {
|
||||
t_config_option_key opt_key = it.key();
|
||||
std::string value_str;
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ void LayerRegion::make_perimeters(const SurfaceCollection &slices, const LayerRe
|
||||
&slices,
|
||||
&compatible_regions,
|
||||
this->layer()->height,
|
||||
this->layer()->slice_z,
|
||||
this->flow(frPerimeter),
|
||||
®ion_config,
|
||||
&this->layer()->object()->config(),
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "libslic3r/AABBTreeLines.hpp"
|
||||
#include "Print.hpp"
|
||||
#include "Algorithm/LineSplit.hpp"
|
||||
#include "libnoise/noise.h"
|
||||
static const int overhang_sampling_number = 6;
|
||||
static const double narrow_loop_length_threshold = 10;
|
||||
static const double min_degree_gap = 0.1;
|
||||
@@ -44,6 +45,14 @@ static double random_value() {
|
||||
return dist(gen);
|
||||
}
|
||||
|
||||
class UniformNoise: public noise::module::Module {
|
||||
public:
|
||||
UniformNoise(): Module (GetSourceModuleCount ()) {};
|
||||
|
||||
virtual int GetSourceModuleCount() const { return 0; }
|
||||
virtual double GetValue(double x, double y, double z) const { return random_value() * 2 - 1; }
|
||||
};
|
||||
|
||||
// Hierarchy of perimeters.
|
||||
class PerimeterGeneratorLoop {
|
||||
public:
|
||||
@@ -66,9 +75,39 @@ public:
|
||||
bool is_internal_contour() const;
|
||||
};
|
||||
|
||||
static std::unique_ptr<noise::module::Module> get_noise_module(const FuzzySkinConfig& cfg) {
|
||||
if (cfg.noise_type == NoiseType::Perlin) {
|
||||
auto perlin_noise = noise::module::Perlin();
|
||||
perlin_noise.SetFrequency(1 / cfg.noise_scale);
|
||||
perlin_noise.SetOctaveCount(cfg.noise_octaves);
|
||||
perlin_noise.SetPersistence(cfg.noise_persistence);
|
||||
return std::make_unique<noise::module::Perlin>(perlin_noise);
|
||||
} else if (cfg.noise_type == NoiseType::Billow) {
|
||||
auto billow_noise = noise::module::Billow();
|
||||
billow_noise.SetFrequency(1 / cfg.noise_scale);
|
||||
billow_noise.SetOctaveCount(cfg.noise_octaves);
|
||||
billow_noise.SetPersistence(cfg.noise_persistence);
|
||||
return std::make_unique<noise::module::Billow>(billow_noise);
|
||||
} else if (cfg.noise_type == NoiseType::RidgedMulti) {
|
||||
auto ridged_multi_noise = noise::module::RidgedMulti();
|
||||
ridged_multi_noise.SetFrequency(1 / cfg.noise_scale);
|
||||
ridged_multi_noise.SetOctaveCount(cfg.noise_octaves);
|
||||
return std::make_unique<noise::module::RidgedMulti>(ridged_multi_noise);
|
||||
} else if (cfg.noise_type == NoiseType::Voronoi) {
|
||||
auto voronoi_noise = noise::module::Voronoi();
|
||||
voronoi_noise.SetFrequency(1 / cfg.noise_scale);
|
||||
voronoi_noise.SetDisplacement(1.0);
|
||||
return std::make_unique<noise::module::Voronoi>(voronoi_noise);
|
||||
} else {
|
||||
return std::make_unique<UniformNoise>();
|
||||
}
|
||||
}
|
||||
|
||||
// Thanks Cura developers for this function.
|
||||
static void fuzzy_polyline(Points& poly, bool closed, const FuzzySkinConfig& cfg)
|
||||
static void fuzzy_polyline(Points& poly, bool closed, coordf_t slice_z, const FuzzySkinConfig& cfg)
|
||||
{
|
||||
std::unique_ptr<noise::module::Module> noise = get_noise_module(cfg);
|
||||
|
||||
const double min_dist_between_points = cfg.point_distance * 3. / 4.; // hardcoded: the point distance may vary between 3/4 and 5/4 the supplied value
|
||||
const double range_random_point_dist = cfg.point_distance / 2.;
|
||||
double dist_left_over = random_value() * (min_dist_between_points / 2.); // the distance to be traversed on the line before making the first new point
|
||||
@@ -90,8 +129,9 @@ static void fuzzy_polyline(Points& poly, bool closed, const FuzzySkinConfig& cfg
|
||||
for (; p0pa_dist < p0p1_size;
|
||||
p0pa_dist += min_dist_between_points + random_value() * range_random_point_dist)
|
||||
{
|
||||
double r = random_value() * (cfg.thickness * 2.) - cfg.thickness;
|
||||
out.emplace_back(*p0 + (p0p1 * (p0pa_dist / p0p1_size) + perp(p0p1).cast<double>().normalized() * r).cast<coord_t>());
|
||||
Point pa = *p0 + (p0p1 * (p0pa_dist / p0p1_size)).cast<coord_t>();
|
||||
double r = noise->GetValue(unscale_(pa.x()), unscale_(pa.y()), slice_z) * cfg.thickness;
|
||||
out.emplace_back(pa + (perp(p0p1).cast<double>().normalized() * r).cast<coord_t>());
|
||||
}
|
||||
dist_left_over = p0pa_dist - p0p1_size;
|
||||
p0 = &p1;
|
||||
@@ -108,8 +148,10 @@ static void fuzzy_polyline(Points& poly, bool closed, const FuzzySkinConfig& cfg
|
||||
}
|
||||
|
||||
// Thanks Cura developers for this function.
|
||||
static void fuzzy_extrusion_line(std::vector<Arachne::ExtrusionJunction>& ext_lines, const FuzzySkinConfig& cfg)
|
||||
static void fuzzy_extrusion_line(std::vector<Arachne::ExtrusionJunction>& ext_lines, coordf_t slice_z, const FuzzySkinConfig& cfg)
|
||||
{
|
||||
std::unique_ptr<noise::module::Module> noise = get_noise_module(cfg);
|
||||
|
||||
const double min_dist_between_points = cfg.point_distance * 3. / 4.; // hardcoded: the point distance may vary between 3/4 and 5/4 the supplied value
|
||||
const double range_random_point_dist = cfg.point_distance / 2.;
|
||||
double dist_left_over = random_value() * (min_dist_between_points / 2.); // the distance to be traversed on the line before making the first new point
|
||||
@@ -128,8 +170,9 @@ static void fuzzy_extrusion_line(std::vector<Arachne::ExtrusionJunction>& ext_li
|
||||
double p0p1_size = p0p1.norm();
|
||||
double p0pa_dist = dist_left_over;
|
||||
for (; p0pa_dist < p0p1_size; p0pa_dist += min_dist_between_points + random_value() * range_random_point_dist) {
|
||||
double r = random_value() * (cfg.thickness * 2.) - cfg.thickness;
|
||||
out.emplace_back(p0->p + (p0p1 * (p0pa_dist / p0p1_size) + perp(p0p1).cast<double>().normalized() * r).cast<coord_t>(), p1.w, p1.perimeter_index);
|
||||
Point pa = p0->p + (p0p1 * (p0pa_dist / p0p1_size)).cast<coord_t>();
|
||||
double r = noise->GetValue(unscale_(pa.x()), unscale_(pa.y()), slice_z) * cfg.thickness;
|
||||
out.emplace_back(pa + (perp(p0p1).cast<double>().normalized() * r).cast<coord_t>(), p1.w, p1.perimeter_index);
|
||||
}
|
||||
dist_left_over = p0pa_dist - p0p1_size;
|
||||
p0 = &p1;
|
||||
@@ -544,7 +587,7 @@ static ExtrusionEntityCollection traverse_loops(const PerimeterGenerator &perime
|
||||
}
|
||||
|
||||
fuzzified = loop.polygon;
|
||||
fuzzy_polyline(fuzzified.points, true, config);
|
||||
fuzzy_polyline(fuzzified.points, true, perimeter_generator.slice_z, config);
|
||||
return &fuzzified;
|
||||
}
|
||||
|
||||
@@ -589,16 +632,17 @@ static ExtrusionEntityCollection traverse_loops(const PerimeterGenerator &perime
|
||||
// Fuzzy splitted polygon
|
||||
if (std::all_of(splitted.begin(), splitted.end(), [](const Algorithm::SplitLineJunction& j) { return j.clipped; })) {
|
||||
// The entire polygon is fuzzified
|
||||
fuzzy_polyline(fuzzified.points, true, r.first);
|
||||
fuzzy_polyline(fuzzified.points, true, perimeter_generator.slice_z, r.first);
|
||||
} else {
|
||||
Points segment;
|
||||
segment.reserve(splitted.size());
|
||||
fuzzified.points.clear();
|
||||
|
||||
const auto fuzzy_current_segment = [&segment, &fuzzified, &r]() {
|
||||
const auto slice_z = perimeter_generator.slice_z;
|
||||
const auto fuzzy_current_segment = [&segment, &fuzzified, &r, slice_z]() {
|
||||
fuzzified.points.push_back(segment.front());
|
||||
const auto back = segment.back();
|
||||
fuzzy_polyline(segment, false, r.first);
|
||||
fuzzy_polyline(segment, false, slice_z, r.first);
|
||||
fuzzified.points.insert(fuzzified.points.end(), segment.begin(), segment.end());
|
||||
fuzzified.points.push_back(back);
|
||||
segment.clear();
|
||||
@@ -970,6 +1014,8 @@ static void smooth_overhang_level(ExtrusionPaths &paths)
|
||||
static ExtrusionEntityCollection traverse_extrusions(const PerimeterGenerator& perimeter_generator, std::vector<PerimeterGeneratorArachneExtrusion>& pg_extrusions,
|
||||
bool &steep_overhang_contour, bool &steep_overhang_hole)
|
||||
{
|
||||
const auto slice_z = perimeter_generator.slice_z;
|
||||
|
||||
// Detect steep overhangs
|
||||
bool overhangs_reverse = perimeter_generator.config->overhang_reverse &&
|
||||
perimeter_generator.layer_id % 2 == 1; // Only calculate overhang degree on even (from GUI POV) layers
|
||||
@@ -989,7 +1035,7 @@ static ExtrusionEntityCollection traverse_extrusions(const PerimeterGenerator& p
|
||||
const auto& config = regions.begin()->first;
|
||||
const bool fuzzify = should_fuzzify(config, perimeter_generator.layer_id, extrusion->inset_idx, is_contour);
|
||||
if (fuzzify)
|
||||
fuzzy_extrusion_line(extrusion->junctions, config);
|
||||
fuzzy_extrusion_line(extrusion->junctions, slice_z, config);
|
||||
} else {
|
||||
// Find all affective regions
|
||||
std::vector<std::pair<const FuzzySkinConfig&, const ExPolygons&>> fuzzified_regions;
|
||||
@@ -1011,17 +1057,17 @@ static ExtrusionEntityCollection traverse_extrusions(const PerimeterGenerator& p
|
||||
// Fuzzy splitted extrusion
|
||||
if (std::all_of(splitted.begin(), splitted.end(), [](const Algorithm::SplitLineJunction& j) { return j.clipped; })) {
|
||||
// The entire polygon is fuzzified
|
||||
fuzzy_extrusion_line(extrusion->junctions, r.first);
|
||||
fuzzy_extrusion_line(extrusion->junctions, slice_z, r.first);
|
||||
} else {
|
||||
const auto current_ext = extrusion->junctions;
|
||||
std::vector<Arachne::ExtrusionJunction> segment;
|
||||
segment.reserve(current_ext.size());
|
||||
extrusion->junctions.clear();
|
||||
|
||||
const auto fuzzy_current_segment = [&segment, extrusion, &r]() {
|
||||
const auto fuzzy_current_segment = [&segment, &extrusion, &r, slice_z]() {
|
||||
extrusion->junctions.push_back(segment.front());
|
||||
const auto back = segment.back();
|
||||
fuzzy_extrusion_line(segment, r.first);
|
||||
fuzzy_extrusion_line(segment, slice_z, r.first);
|
||||
extrusion->junctions.insert(extrusion->junctions.end(), segment.begin(), segment.end());
|
||||
extrusion->junctions.push_back(back);
|
||||
segment.clear();
|
||||
@@ -1858,7 +1904,11 @@ static void group_region_by_fuzzify(PerimeterGenerator& g)
|
||||
region_config.fuzzy_skin,
|
||||
scaled<coord_t>(region_config.fuzzy_skin_thickness.value),
|
||||
scaled<coord_t>(region_config.fuzzy_skin_point_distance.value),
|
||||
region_config.fuzzy_skin_first_layer
|
||||
region_config.fuzzy_skin_first_layer,
|
||||
region_config.fuzzy_skin_noise_type,
|
||||
region_config.fuzzy_skin_scale,
|
||||
region_config.fuzzy_skin_octaves,
|
||||
region_config.fuzzy_skin_persistence
|
||||
};
|
||||
auto& surfaces = regions[cfg];
|
||||
for (const auto& surface : region->slices.surfaces) {
|
||||
|
||||
@@ -16,10 +16,21 @@ struct FuzzySkinConfig
|
||||
coord_t thickness;
|
||||
coord_t point_distance;
|
||||
bool fuzzy_first_layer;
|
||||
NoiseType noise_type;
|
||||
double noise_scale;
|
||||
int noise_octaves;
|
||||
double noise_persistence;
|
||||
|
||||
bool operator==(const FuzzySkinConfig& r) const
|
||||
{
|
||||
return type == r.type && thickness == r.thickness && point_distance == r.point_distance && fuzzy_first_layer == r.fuzzy_first_layer;
|
||||
return type == r.type
|
||||
&& thickness == r.thickness
|
||||
&& point_distance == r.point_distance
|
||||
&& fuzzy_first_layer == r.fuzzy_first_layer
|
||||
&& noise_type == r.noise_type
|
||||
&& noise_scale == r.noise_scale
|
||||
&& noise_octaves == r.noise_octaves
|
||||
&& noise_persistence == r.noise_persistence;
|
||||
}
|
||||
|
||||
bool operator!=(const FuzzySkinConfig& r) const { return !(*this == r); }
|
||||
@@ -35,6 +46,10 @@ template<> struct hash<Slic3r::FuzzySkinConfig>
|
||||
boost::hash_combine(seed, std::hash<coord_t>{}(c.thickness));
|
||||
boost::hash_combine(seed, std::hash<coord_t>{}(c.point_distance));
|
||||
boost::hash_combine(seed, std::hash<bool>{}(c.fuzzy_first_layer));
|
||||
boost::hash_combine(seed, std::hash<Slic3r::NoiseType>{}(c.noise_type));
|
||||
boost::hash_combine(seed, std::hash<double>{}(c.noise_scale));
|
||||
boost::hash_combine(seed, std::hash<int>{}(c.noise_octaves));
|
||||
boost::hash_combine(seed, std::hash<double>{}(c.noise_persistence));
|
||||
return seed;
|
||||
}
|
||||
};
|
||||
@@ -51,6 +66,7 @@ public:
|
||||
const ExPolygons *lower_slices;
|
||||
double layer_height;
|
||||
int layer_id;
|
||||
coordf_t slice_z;
|
||||
Flow perimeter_flow;
|
||||
Flow ext_perimeter_flow;
|
||||
Flow overhang_flow;
|
||||
@@ -83,6 +99,7 @@ public:
|
||||
const SurfaceCollection* slices,
|
||||
const LayerRegionPtrs *compatible_regions,
|
||||
double layer_height,
|
||||
coordf_t slice_z,
|
||||
Flow flow,
|
||||
const PrintRegionConfig* config,
|
||||
const PrintObjectConfig* object_config,
|
||||
@@ -98,7 +115,7 @@ public:
|
||||
//BBS
|
||||
ExPolygons* fill_no_overlap)
|
||||
: slices(slices), compatible_regions(compatible_regions), upper_slices(nullptr), lower_slices(nullptr), layer_height(layer_height),
|
||||
layer_id(-1), perimeter_flow(flow), ext_perimeter_flow(flow),
|
||||
slice_z(slice_z), layer_id(-1), perimeter_flow(flow), ext_perimeter_flow(flow),
|
||||
overhang_flow(flow), solid_infill_flow(flow),
|
||||
config(config), object_config(object_config), print_config(print_config),
|
||||
m_spiral_vase(spiral_mode),
|
||||
|
||||
@@ -576,9 +576,10 @@ std::string Preset::label(bool no_alias) const
|
||||
|
||||
bool is_compatible_with_print(const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_print, const PresetWithVendorProfile &active_printer)
|
||||
{
|
||||
if (preset.vendor != nullptr && preset.vendor != active_printer.vendor)
|
||||
// The current profile has a vendor assigned and it is different from the active print's vendor.
|
||||
return false;
|
||||
// Orca: we allow cross vendor compatibility
|
||||
// if (preset.vendor != nullptr && preset.vendor != active_printer.vendor)
|
||||
// // The current profile has a vendor assigned and it is different from the active print's vendor.
|
||||
// return false;
|
||||
auto &condition = preset.preset.compatible_prints_condition();
|
||||
auto *compatible_prints = dynamic_cast<const ConfigOptionStrings*>(preset.preset.config.option("compatible_prints"));
|
||||
bool has_compatible_prints = compatible_prints != nullptr && ! compatible_prints->values.empty();
|
||||
@@ -613,9 +614,19 @@ bool is_compatible_with_parent_printer(const PresetWithVendorProfile& preset, co
|
||||
|
||||
bool is_compatible_with_printer(const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_printer, const DynamicPrintConfig *extra_config)
|
||||
{
|
||||
if (preset.vendor != nullptr && preset.vendor != active_printer.vendor)
|
||||
// The current profile has a vendor assigned and it is different from the active print's vendor.
|
||||
return false;
|
||||
// Orca: we allow cross vendor compatibility
|
||||
// if (preset.vendor != nullptr && preset.vendor != active_printer.vendor)
|
||||
// // The current profile has a vendor assigned and it is different from the active print's vendor.
|
||||
// return false;
|
||||
|
||||
// Orca: check excluded printers
|
||||
if (preset.vendor != nullptr && preset.preset.type == Preset::TYPE_FILAMENT) {
|
||||
const auto& excluded_printers = preset.preset.m_excluded_from;
|
||||
const auto excluded = preset.vendor->name == PresetBundle::ORCA_FILAMENT_LIBRARY &&
|
||||
excluded_printers.find(active_printer.preset.name) != excluded_printers.end();
|
||||
if (excluded)
|
||||
return false;
|
||||
}
|
||||
auto &condition = preset.preset.compatible_printers_condition();
|
||||
auto *compatible_printers = dynamic_cast<const ConfigOptionStrings*>(preset.preset.config.option("compatible_printers"));
|
||||
bool has_compatible_printers = compatible_printers != nullptr && ! compatible_printers->values.empty();
|
||||
@@ -629,10 +640,9 @@ bool is_compatible_with_printer(const PresetWithVendorProfile &preset, const Pre
|
||||
}
|
||||
}
|
||||
return preset.preset.is_default || active_printer.preset.name.empty() || !has_compatible_printers ||
|
||||
std::find(compatible_printers->values.begin(), compatible_printers->values.end(), active_printer.preset.name) !=
|
||||
compatible_printers->values.end()
|
||||
//BBS
|
||||
|| (!active_printer.preset.is_system && is_compatible_with_parent_printer(preset, active_printer));
|
||||
std::find(compatible_printers->values.begin(), compatible_printers->values.end(), active_printer.preset.name) !=
|
||||
compatible_printers->values.end() ||
|
||||
(!active_printer.preset.is_system && is_compatible_with_parent_printer(preset, active_printer));
|
||||
}
|
||||
|
||||
bool is_compatible_with_printer(const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_printer)
|
||||
@@ -779,7 +789,7 @@ static std::vector<std::string> s_Preset_print_options {
|
||||
"minimum_sparse_infill_area", "reduce_infill_retraction","internal_solid_infill_pattern","gap_fill_target",
|
||||
"ironing_type", "ironing_pattern", "ironing_flow", "ironing_speed", "ironing_spacing", "ironing_angle", "ironing_inset",
|
||||
"max_travel_detour_distance",
|
||||
"fuzzy_skin", "fuzzy_skin_thickness", "fuzzy_skin_point_distance", "fuzzy_skin_first_layer",
|
||||
"fuzzy_skin", "fuzzy_skin_thickness", "fuzzy_skin_point_distance", "fuzzy_skin_first_layer", "fuzzy_skin_noise_type", "fuzzy_skin_scale", "fuzzy_skin_octaves", "fuzzy_skin_persistence",
|
||||
"max_volumetric_extrusion_rate_slope", "max_volumetric_extrusion_rate_slope_segment_length","extrusion_rate_smoothing_external_perimeter_only",
|
||||
"inner_wall_speed", "outer_wall_speed", "sparse_infill_speed", "internal_solid_infill_speed",
|
||||
"top_surface_speed", "support_speed", "support_object_xy_distance", "support_interface_speed",
|
||||
@@ -1145,7 +1155,7 @@ void PresetCollection::load_presets(
|
||||
if (key_values.find("instantiation") != key_values.end())
|
||||
preset.is_visible = key_values["instantiation"] != "false";
|
||||
|
||||
//BBS: use inherit config as the base
|
||||
//Orca: find and use the inherit config as the base
|
||||
Preset* inherit_preset = nullptr;
|
||||
ConfigOption* inherits_config = config.option(BBL_JSON_KEY_INHERITS);
|
||||
|
||||
@@ -1154,6 +1164,12 @@ void PresetCollection::load_presets(
|
||||
ConfigOptionString * option_str = dynamic_cast<ConfigOptionString *> (inherits_config);
|
||||
std::string inherits_value = option_str->value;
|
||||
inherit_preset = this->find_preset(inherits_value, false, true);
|
||||
// Orca: try to find if the parent preset has been renamed
|
||||
if (inherit_preset == nullptr) {
|
||||
auto it = this->find_preset_renamed(inherits_value);
|
||||
if (it != m_presets.end())
|
||||
inherit_preset = &(*it);
|
||||
}
|
||||
} else {
|
||||
;
|
||||
}
|
||||
@@ -2123,6 +2139,7 @@ bool PresetCollection::clone_presets(std::vector<Preset const *> const &presets,
|
||||
auto &preset = new_presets.back();
|
||||
preset.vendor = nullptr;
|
||||
preset.renamed_from.clear();
|
||||
preset.m_excluded_from.clear();
|
||||
preset.setting_id.clear();
|
||||
preset.inherits().clear();
|
||||
preset.is_default = false;
|
||||
@@ -2251,6 +2268,7 @@ void PresetCollection::save_current_preset(const std::string &new_name, bool det
|
||||
preset.inherits().clear();
|
||||
preset.alias.clear();
|
||||
preset.renamed_from.clear();
|
||||
preset.m_excluded_from.clear();
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": save preset %1% , with detach")%new_name;
|
||||
}
|
||||
//BBS: add lock logic for sync preset in background
|
||||
@@ -2278,6 +2296,7 @@ void PresetCollection::save_current_preset(const std::string &new_name, bool det
|
||||
preset.vendor = nullptr;
|
||||
preset.alias.clear();
|
||||
preset.renamed_from.clear();
|
||||
preset.m_excluded_from.clear();
|
||||
preset.setting_id.clear();
|
||||
if (detach) {
|
||||
// Clear the link to the parent profile.
|
||||
@@ -2525,6 +2544,17 @@ Preset* PresetCollection::find_preset(const std::string &name, bool first_visibl
|
||||
first_visible_if_not_found ? &this->first_visible() : nullptr;
|
||||
}
|
||||
|
||||
const Preset* PresetCollection::find_preset2(const std::string& name) const
|
||||
{
|
||||
auto preset = const_cast<PresetCollection*>(this)->find_preset(name, false, true);
|
||||
if (preset == nullptr) {
|
||||
auto _name = get_preset_name_renamed(name);
|
||||
if(_name != nullptr)
|
||||
preset = const_cast<PresetCollection*>(this)->find_preset(*_name, false, true);
|
||||
}
|
||||
return preset;
|
||||
}
|
||||
|
||||
// Return index of the first visible preset. Certainly at least the '- default -' preset shall be visible.
|
||||
size_t PresetCollection::first_visible_idx() const
|
||||
{
|
||||
@@ -2859,6 +2889,38 @@ void PresetCollection::update_map_alias_to_profile_name()
|
||||
//std::sort(m_map_alias_to_profile_name.begin(), m_map_alias_to_profile_name.end(), [](auto &l, auto &r) { return l.first < r.first; });
|
||||
}
|
||||
|
||||
void PresetCollection::update_library_profile_excluded_from()
|
||||
{
|
||||
// Orca: Collect all filament presets that has empty compatible_printers and belongs to the Orca Filament Library.
|
||||
std::map<std::string, std::set<std::string>*> excluded_froms;
|
||||
for (Preset& preset : m_presets) {
|
||||
if (preset.vendor != nullptr && preset.vendor->name == PresetBundle::ORCA_FILAMENT_LIBRARY) {
|
||||
// check if the preset has empty compatible_printers
|
||||
const auto* compatible_printers = dynamic_cast<const ConfigOptionStrings*>(preset.config.option("compatible_printers"));
|
||||
if (compatible_printers == nullptr || compatible_printers->values.empty())
|
||||
excluded_froms[preset.alias] = &preset.m_excluded_from;
|
||||
}
|
||||
}
|
||||
|
||||
// Check all presets that has the same alias as the filament presets with empty compatible_printers in Orca Filament Library.
|
||||
for (const Preset& preset : m_presets) {
|
||||
if (preset.vendor == nullptr || preset.vendor->name == PresetBundle::ORCA_FILAMENT_LIBRARY)
|
||||
continue;
|
||||
|
||||
const auto* compatible_printers = dynamic_cast<const ConfigOptionStrings*>(preset.config.option("compatible_printers"));
|
||||
// All profiles in concrete vendor profile shouldn't have empty compatible_printers, but here we check it for safety.
|
||||
if (compatible_printers == nullptr || compatible_printers->values.empty())
|
||||
continue;
|
||||
auto itr = excluded_froms.find(preset.alias);
|
||||
if (itr != excluded_froms.end()) {
|
||||
// Add the printer models to the excluded_from list.
|
||||
for (const std::string& printer_name : compatible_printers->values) {
|
||||
itr->second->insert(printer_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PresetCollection::update_map_system_profile_renamed()
|
||||
{
|
||||
m_map_system_profile_renamed.clear();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <deque>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <functional>
|
||||
@@ -63,7 +64,8 @@
|
||||
#define BBL_JSON_KEY_DEFAULT_MATERIALS "default_materials"
|
||||
#define BBL_JSON_KEY_MODEL_ID "model_id"
|
||||
|
||||
//BBL: json path
|
||||
// Orca extension
|
||||
#define ORCA_JSON_KEY_RENAMED_FROM "renamed_from"
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
@@ -232,6 +234,11 @@ public:
|
||||
// and to match the "inherits" field of user profiles with updated system profiles.
|
||||
std::vector<std::string> renamed_from;
|
||||
|
||||
// Orca: maintain a list of printer models that are excluded from this preset, designed for filaments without compatible_printer defined
|
||||
// (hence they are visible to all printer models by default) in Orca Filament Library. However, we might have speciliazed filament for
|
||||
// certain printer models defined in the vendor profile as well, in this case we want to hide this generic preset for these printer models.
|
||||
std::set<std::string> m_excluded_from;
|
||||
|
||||
//BBS
|
||||
Semver version; // version of preset
|
||||
std::string ini_str; // ini string of preset
|
||||
@@ -595,6 +602,8 @@ public:
|
||||
Preset* find_preset(const std::string &name, bool first_visible_if_not_found = false, bool real = false);
|
||||
const Preset* find_preset(const std::string &name, bool first_visible_if_not_found = false) const
|
||||
{ return const_cast<PresetCollection*>(this)->find_preset(name, first_visible_if_not_found); }
|
||||
// Orca: find preset, if not found, keep searching in the renamed history
|
||||
const Preset* find_preset2(const std::string &name) const;
|
||||
|
||||
size_t first_visible_idx() const;
|
||||
// Return index of the first compatible preset. Certainly at least the '- default -' preset shall be compatible.
|
||||
@@ -718,6 +727,10 @@ protected:
|
||||
// Update m_map_system_profile_renamed from loaded system profiles.
|
||||
void update_map_system_profile_renamed();
|
||||
|
||||
// Orca: update m_excluded_from loaded system profiles.
|
||||
void update_library_profile_excluded_from();
|
||||
|
||||
|
||||
void set_custom_preset_alias(Preset &preset);
|
||||
|
||||
private:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -160,7 +160,12 @@ public:
|
||||
// and the system profiles will point to the VendorProfile instances owned by PresetBundle::vendors.
|
||||
VendorMap vendors;
|
||||
|
||||
struct ObsoletePresets {
|
||||
// Orca: for OrcaFilamentLibrary
|
||||
std::map<std::string, DynamicPrintConfig> m_config_maps;
|
||||
std::map<std::string, std::string> m_filament_id_maps;
|
||||
|
||||
struct ObsoletePresets
|
||||
{
|
||||
std::vector<std::string> prints;
|
||||
std::vector<std::string> sla_prints;
|
||||
std::vector<std::string> filaments;
|
||||
@@ -212,9 +217,9 @@ public:
|
||||
// Don't do any config substitutions when loading a system profile, perform and report substitutions otherwise.
|
||||
/*std::pair<PresetsConfigSubstitutions, size_t> load_configbundle(
|
||||
const std::string &path, LoadConfigBundleAttributes flags, ForwardCompatibilitySubstitutionRule compatibility_rule);*/
|
||||
//BBS: add json related logic
|
||||
//Orca: load config bundle from json, pass the base bundle to support cross vendor inheritance
|
||||
std::pair<PresetsConfigSubstitutions, size_t> load_vendor_configs_from_json(
|
||||
const std::string &path, const std::string &vendor_name, LoadConfigBundleAttributes flags, ForwardCompatibilitySubstitutionRule compatibility_rule);
|
||||
const std::string &path, const std::string &vendor_name, LoadConfigBundleAttributes flags, ForwardCompatibilitySubstitutionRule compatibility_rule, const PresetBundle* base_bundle = nullptr);
|
||||
|
||||
// Export a config bundle file containing all the presets and the names of the active presets.
|
||||
//void export_configbundle(const std::string &path, bool export_system_settings = false, bool export_physical_printers = false);
|
||||
@@ -261,11 +266,13 @@ public:
|
||||
std::pair<PresetsConfigSubstitutions, std::string> load_system_filaments_json(ForwardCompatibilitySubstitutionRule compatibility_rule);
|
||||
VendorProfile get_custom_vendor_models() const;
|
||||
|
||||
//BBS: add BBL as default
|
||||
static const char *BBL_BUNDLE;
|
||||
static const char *BBL_DEFAULT_PRINTER_MODEL;
|
||||
static const char *BBL_DEFAULT_PRINTER_VARIANT;
|
||||
static const char *BBL_DEFAULT_FILAMENT;
|
||||
//orca: add 'custom' as default
|
||||
static const char *ORCA_DEFAULT_BUNDLE;
|
||||
static const char *ORCA_DEFAULT_PRINTER_MODEL;
|
||||
static const char *ORCA_DEFAULT_PRINTER_VARIANT;
|
||||
static const char *ORCA_DEFAULT_FILAMENT;
|
||||
static const char *ORCA_FILAMENT_LIBRARY;
|
||||
|
||||
|
||||
static std::array<Preset::Type, 3> types_list(PrinterTechnology pt) {
|
||||
if (pt == ptFFF)
|
||||
|
||||
@@ -123,6 +123,15 @@ static t_config_enum_values s_keys_map_FuzzySkinType {
|
||||
};
|
||||
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(FuzzySkinType)
|
||||
|
||||
static t_config_enum_values s_keys_map_NoiseType {
|
||||
{ "classic", int(NoiseType::Classic) },
|
||||
{ "perlin", int(NoiseType::Perlin) },
|
||||
{ "billow", int(NoiseType::Billow) },
|
||||
{ "ridgedmulti", int(NoiseType::RidgedMulti) },
|
||||
{ "voronoi", int(NoiseType::Voronoi) }
|
||||
};
|
||||
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(NoiseType)
|
||||
|
||||
static t_config_enum_values s_keys_map_InfillPattern {
|
||||
{ "concentric", ipConcentric },
|
||||
{ "zig-zag", ipRectilinear },
|
||||
@@ -1262,38 +1271,38 @@ void PrintConfigDef::init_fff_params()
|
||||
|
||||
def = this->add("compatible_printers", coStrings);
|
||||
def->label = L("Compatible machine");
|
||||
def->mode = comDevelop;
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionStrings());
|
||||
def->cli = ConfigOptionDef::nocli;
|
||||
|
||||
//BBS.
|
||||
def = this->add("upward_compatible_machine", coStrings);
|
||||
def->label = L("upward compatible machine");
|
||||
def->mode = comDevelop;
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionStrings());
|
||||
def->cli = ConfigOptionDef::nocli;
|
||||
|
||||
def = this->add("compatible_printers_condition", coString);
|
||||
def->label = L("Compatible machine condition");
|
||||
//def->tooltip = L("A boolean expression using the configuration values of an active printer profile. "
|
||||
// "If this expression evaluates to true, this profile is considered compatible "
|
||||
// "with the active printer profile.");
|
||||
def->mode = comDevelop;
|
||||
def->tooltip = L("A boolean expression using the configuration values of an active printer profile. "
|
||||
"If this expression evaluates to true, this profile is considered compatible "
|
||||
"with the active printer profile.");
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionString());
|
||||
def->cli = ConfigOptionDef::nocli;
|
||||
|
||||
def = this->add("compatible_prints", coStrings);
|
||||
def->label = L("Compatible process profiles");
|
||||
def->mode = comDevelop;
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionStrings());
|
||||
def->cli = ConfigOptionDef::nocli;
|
||||
|
||||
def = this->add("compatible_prints_condition", coString);
|
||||
def->label = L("Compatible process profiles condition");
|
||||
//def->tooltip = L("A boolean expression using the configuration values of an active print profile. "
|
||||
// "If this expression evaluates to true, this profile is considered compatible "
|
||||
// "with the active print profile.");
|
||||
def->mode = comDevelop;
|
||||
def->tooltip = L("A boolean expression using the configuration values of an active print profile. "
|
||||
"If this expression evaluates to true, this profile is considered compatible "
|
||||
"with the active print profile.");
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionString());
|
||||
def->cli = ConfigOptionDef::nocli;
|
||||
|
||||
@@ -2632,6 +2641,57 @@ void PrintConfigDef::init_fff_params()
|
||||
def->mode = comSimple;
|
||||
def->set_default_value(new ConfigOptionBool(0));
|
||||
|
||||
def = this->add("fuzzy_skin_noise_type", coEnum);
|
||||
def->label = L("Fuzzy skin noise type");
|
||||
def->category = L("Others");
|
||||
def->tooltip = L("Noise type to use for fuzzy skin generation.\n"
|
||||
"Classic: Classic uniform random noise.\n"
|
||||
"Perlin: Perlin noise, which gives a more consistent texture.\n"
|
||||
"Billow: Similar to perlin noise, but clumpier.\n"
|
||||
"Ridged Multifractal: Ridged noise with sharp, jagged features. Creates marble-like textures.\n"
|
||||
"Voronoi: Divides the surface into voronoi cells, and displaces each one by a random amount. Creates a patchwork texture.");
|
||||
def->enum_keys_map = &ConfigOptionEnum<NoiseType>::get_enum_values();
|
||||
def->enum_values.push_back("classic");
|
||||
def->enum_values.push_back("perlin");
|
||||
def->enum_values.push_back("billow");
|
||||
def->enum_values.push_back("ridgedmulti");
|
||||
def->enum_values.push_back("voronoi");
|
||||
def->enum_labels.push_back(L("Classic"));
|
||||
def->enum_labels.push_back(L("Perlin"));
|
||||
def->enum_labels.push_back(L("Billow"));
|
||||
def->enum_labels.push_back(L("Ridged Multifractal"));
|
||||
def->enum_labels.push_back(L("Voronoi"));
|
||||
def->mode = comSimple;
|
||||
def->set_default_value(new ConfigOptionEnum<NoiseType>(NoiseType::Classic));
|
||||
|
||||
def = this->add("fuzzy_skin_scale", coFloat);
|
||||
def->label = L("Fuzzy skin feature size");
|
||||
def->category = L("Others");
|
||||
def->tooltip = L("The base size of the coherent noise features, in mm. Higher values will result in larger features.");
|
||||
def->sidetext = L("mm");
|
||||
def->min = 0.1;
|
||||
def->max = 500;
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloat(1.0));
|
||||
|
||||
def = this->add("fuzzy_skin_octaves", coInt);
|
||||
def->label = L("Fuzzy Skin Noise Octaves");
|
||||
def->category = L("Others");
|
||||
def->tooltip = L("The number of octaves of coherent noise to use. Higher values increase the detail of the noise, but also increase computation time.");
|
||||
def->min = 1;
|
||||
def->max = 10;
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionInt(4));
|
||||
|
||||
def = this->add("fuzzy_skin_persistence", coFloat);
|
||||
def->label = L("Fuzzy skin noise persistence");
|
||||
def->category = L("Others");
|
||||
def->tooltip = L("The decay rate for higher octaves of the coherent noise. Lower values will result in smoother noise.");
|
||||
def->min = 0.01;
|
||||
def->max = 1;
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloat(0.5));
|
||||
|
||||
def = this->add("filter_out_gap_fill", coFloat);
|
||||
def->label = L("Filter out tiny gaps");
|
||||
def->category = L("Layers and Perimeters");
|
||||
|
||||
@@ -41,6 +41,14 @@ enum class FuzzySkinType {
|
||||
AllWalls,
|
||||
};
|
||||
|
||||
enum class NoiseType {
|
||||
Classic,
|
||||
Perlin,
|
||||
Billow,
|
||||
RidgedMulti,
|
||||
Voronoi,
|
||||
};
|
||||
|
||||
enum PrintHostType {
|
||||
htPrusaLink, htPrusaConnect, htOctoPrint, htDuet, htFlashAir, htAstroBox, htRepetier, htMKS, htESP3D, htCrealityPrint, htObico, htFlashforge, htSimplyPrint
|
||||
};
|
||||
@@ -402,6 +410,7 @@ static std::string get_bed_temp_1st_layer_key(const BedType type)
|
||||
CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(PrinterTechnology)
|
||||
CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(GCodeFlavor)
|
||||
CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(FuzzySkinType)
|
||||
CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(NoiseType)
|
||||
CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(InfillPattern)
|
||||
CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(IroningType)
|
||||
CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(SlicingMode)
|
||||
@@ -917,6 +926,10 @@ PRINT_CONFIG_CLASS_DEFINE(
|
||||
((ConfigOptionFloat, fuzzy_skin_thickness))
|
||||
((ConfigOptionFloat, fuzzy_skin_point_distance))
|
||||
((ConfigOptionBool, fuzzy_skin_first_layer))
|
||||
((ConfigOptionEnum<NoiseType>, fuzzy_skin_noise_type))
|
||||
((ConfigOptionFloat, fuzzy_skin_scale))
|
||||
((ConfigOptionInt, fuzzy_skin_octaves))
|
||||
((ConfigOptionFloat, fuzzy_skin_persistence))
|
||||
((ConfigOptionFloat, gap_infill_speed))
|
||||
((ConfigOptionInt, sparse_infill_filament))
|
||||
((ConfigOptionFloatOrPercent, sparse_infill_line_width))
|
||||
|
||||
@@ -1117,6 +1117,10 @@ bool PrintObject::invalidate_state_by_config_options(
|
||||
|| opt_key == "fuzzy_skin_thickness"
|
||||
|| opt_key == "fuzzy_skin_point_distance"
|
||||
|| opt_key == "fuzzy_skin_first_layer"
|
||||
|| opt_key == "fuzzy_skin_noise_type"
|
||||
|| opt_key == "fuzzy_skin_scale"
|
||||
|| opt_key == "fuzzy_skin_octaves"
|
||||
|| opt_key == "fuzzy_skin_persistence"
|
||||
|| opt_key == "detect_overhang_wall"
|
||||
|| opt_key == "overhang_reverse"
|
||||
|| opt_key == "overhang_reverse_internal_only"
|
||||
|
||||
Reference in New Issue
Block a user