OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::anonymous_namespace{PrintConfig.cpp} Namespace Reference

Functions

static void normalize_stride2_floats (ConfigOptionFloats &opt, size_t expected_size)
static void log_normalize_legacy_vector_size (const char *fn, const std::string &key, int stride, size_t src_size, size_t dest_size, size_t expected_size, size_t restore_n, int cur_variant_count, int target_variant_count, size_t cur_ids, size_t target_ids, const ConfigOption *opt_src, const ConfigOption *opt_target)
static bool looks_like_bed_exclusion_volume_syntax (const std::string &value)
static bool parse_double_token (const std::string &text, double &out)
static bool parse_z_range_token (const std::string &token_in, const double printable_height, double &z_min, double &z_max, bool &has_z)
static std::optional< Polygon > parse_exclude_polygon_points (const std::string &points_str)
static void append_legacy_bed_exclude_regions (std::vector< BedExcludeRegion > &out, const Pointfs &legacy_points, const double printable_height)
static void append_bed_exclusion_volume_regions (std::vector< BedExcludeRegion > &out, const std::string &region_specs_raw, const double printable_height)
static bool has_nonempty_string (const std::string &value)
static bool collision_volumes_configured (const std::string &shared_specs, const BedExcludeVolumeMode mode, const std::vector< std::string > &per_extruder_specs)
static std::vector< BedExcludeRegion > parse_master_bed_excluded_regions (const Pointfs &legacy_points, const std::string &shared_specs, const bool use_collision_volumes, const BedExcludeVolumeMode mode, const double printable_height)
static void project_bed_material_keepouts (std::vector< BedExcludeRegion > &regions, const ConfigBase &cfg)
static std::vector< BedExcludeRegion > resolve_bed_excluded_regions (const std::vector< BedExcludeRegion > &master_regions, const BedExcludeVolumeMode mode, const std::vector< std::string > &per_extruder_specs, const std::vector< Vec2d > &extruder_offsets, const size_t reference_extruder, const size_t extruder_id, const double printable_height)
static size_t bed_exclusion_extruder_count (const size_t nozzle_count, const size_t offset_count, const size_t per_extruder_count)
static std::vector< BedExcludeRegion > flatten_bed_excluded_regions (const BedExcludeVolumeMode mode, std::vector< std::vector< BedExcludeRegion > > regions_by_extruder)

Function Documentation

◆ append_bed_exclusion_volume_regions()

void Slic3r::anonymous_namespace{PrintConfig.cpp}::append_bed_exclusion_volume_regions ( std::vector< BedExcludeRegion > & out,
const std::string & region_specs_raw,
const double printable_height )
static
13995{
13996 std::vector<std::string> region_specs;
13997 boost::split(region_specs, region_specs_raw, boost::is_any_of("|\n"));
13998
13999 for (const std::string &spec_raw : region_specs) {
14000 std::string spec = spec_raw;
14001 boost::trim(spec);
14002 if (spec.empty())
14003 continue;
14004
14005 std::vector<std::string> fields;
14006 boost::split(fields, spec, boost::is_any_of(";"));
14007
14008 double z_min = 0.0;
14009 double z_max = printable_height;
14010 bool has_z_range = false;
14011 std::string points_field;
14012 bool invalid_z = false;
14013
14014 for (std::string field : fields) {
14015 boost::trim(field);
14016 if (field.empty())
14017 continue;
14018
14019 bool parsed_z_range = parse_z_range_token(field, printable_height, z_min, z_max, has_z_range);
14020 if (parsed_z_range)
14021 continue;
14022
14023 if (field.find("..") != std::string::npos && field.find('x') == std::string::npos) {
14024 invalid_z = true;
14025 break;
14026 }
14027
14028 if (boost::algorithm::istarts_with(field, "points="))
14029 field = field.substr(std::string("points=").size());
14030 else if (boost::algorithm::istarts_with(field, "polygon="))
14031 field = field.substr(std::string("polygon=").size());
14032
14033 points_field = field;
14034 }
14035
14036 if (invalid_z)
14037 continue;
14038
14039 if (! has_z_range) {
14040 z_min = 0.0;
14041 z_max = printable_height;
14042 }
14043
14044 if (z_min >= z_max)
14045 continue;
14046
14047 std::optional<Polygon> polygon = parse_exclude_polygon_points(points_field);
14048 if (! polygon)
14049 continue;
14050
14051 out.push_back({ std::move(*polygon), z_min, z_max,
14053 }
14054}
static bool parse_z_range_token(const std::string &token_in, const double printable_height, double &z_min, double &z_max, bool &has_z)
Definition PrintConfig.cpp:13904
static std::optional< Polygon > parse_exclude_polygon_points(const std::string &points_str)
Definition PrintConfig.cpp:13940
zaa_minimize_perimeter_height printable_height((ConfigOptionFloatsNullable, extruder_printable_height))((ConfigOptionPoint
@ CollisionVolume
Definition PrintConfig.hpp:2548

References append_bed_exclusion_volume_regions(), Slic3r::BedExcludeRegion::CollisionVolume, parse_exclude_polygon_points(), parse_z_range_token(), and Slic3r::printable_height().

Referenced by append_bed_exclusion_volume_regions(), parse_master_bed_excluded_regions(), and resolve_bed_excluded_regions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ append_legacy_bed_exclude_regions()

void Slic3r::anonymous_namespace{PrintConfig.cpp}::append_legacy_bed_exclude_regions ( std::vector< BedExcludeRegion > & out,
const Pointfs & legacy_points,
const double printable_height )
static
13977{
13978 if (legacy_points.size() < 3)
13979 return;
13980
13981 Polygon polygon;
13982 polygon.points.reserve(legacy_points.size());
13983 for (const Vec2d &pt : legacy_points)
13984 polygon.points.emplace_back(scale_(pt.x()), scale_(pt.y()));
13985 polygon.make_counter_clockwise();
13986
13987 out.push_back({ std::move(polygon), 0.0, printable_height,
13989}
Points points
Definition MultiPoint.hpp:22
Definition Polygon.hpp:31
bool make_counter_clockwise()
Definition Polygon.cpp:94
#define scale_(val)
Definition libslic3r.h:106
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67
@ MaterialKeepout
Definition PrintConfig.hpp:2547

References append_legacy_bed_exclude_regions(), Slic3r::Polygon::make_counter_clockwise(), Slic3r::BedExcludeRegion::MaterialKeepout, Slic3r::MultiPoint::points, Slic3r::printable_height(), and scale_.

Referenced by append_legacy_bed_exclude_regions(), and parse_master_bed_excluded_regions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bed_exclusion_extruder_count()

size_t Slic3r::anonymous_namespace{PrintConfig.cpp}::bed_exclusion_extruder_count ( const size_t nozzle_count,
const size_t offset_count,
const size_t per_extruder_count )
static
14154{
14155 return std::max<size_t>(1, std::max({ nozzle_count, offset_count, per_extruder_count }));
14156}

References bed_exclusion_extruder_count().

Referenced by bed_exclusion_extruder_count().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ collision_volumes_configured()

bool Slic3r::anonymous_namespace{PrintConfig.cpp}::collision_volumes_configured ( const std::string & shared_specs,
const BedExcludeVolumeMode mode,
const std::vector< std::string > & per_extruder_specs )
static
14065{
14067 return std::any_of(per_extruder_specs.begin(), per_extruder_specs.end(), has_nonempty_string);
14068 return has_nonempty_string(shared_specs);
14069}
static bool has_nonempty_string(const std::string &value)
Definition PrintConfig.cpp:14056
@ PerExtruder
Definition PrintConfig.hpp:645

References collision_volumes_configured(), has_nonempty_string(), and Slic3r::PerExtruder.

Referenced by collision_volumes_configured().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ flatten_bed_excluded_regions()

std::vector< BedExcludeRegion > Slic3r::anonymous_namespace{PrintConfig.cpp}::flatten_bed_excluded_regions ( const BedExcludeVolumeMode mode,
std::vector< std::vector< BedExcludeRegion > > regions_by_extruder )
static
14161{
14162 if (regions_by_extruder.empty())
14163 return {};
14164 if (mode == BedExcludeVolumeMode::Shared)
14165 return std::move(regions_by_extruder.front());
14166
14167 std::vector<BedExcludeRegion> flattened;
14168 // A shared legacy area is present in every resolved nozzle group so object
14169 // validation sees it for every tool. Flatten it only once, while retaining
14170 // every nozzle-specific collision volume.
14171 bool material_keepout_added = false;
14172 for (std::vector<BedExcludeRegion> &regions : regions_by_extruder) {
14173 for (BedExcludeRegion &region : regions) {
14174 if (!region.is_collision_volume()) {
14175 if (material_keepout_added)
14176 continue;
14177 material_keepout_added = true;
14178 }
14179 flattened.emplace_back(std::move(region));
14180 }
14181 }
14182 return flattened;
14183}
@ Shared
Definition PrintConfig.hpp:643
Definition PrintConfig.hpp:2545

References flatten_bed_excluded_regions(), and Slic3r::Shared.

Referenced by flatten_bed_excluded_regions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ has_nonempty_string()

bool Slic3r::anonymous_namespace{PrintConfig.cpp}::has_nonempty_string ( const std::string & value)
static
14057{
14058 return std::any_of(value.begin(), value.end(), [](const char c) { return !std::isspace(static_cast<unsigned char>(c)); });
14059}

References has_nonempty_string().

Referenced by collision_volumes_configured(), and has_nonempty_string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ log_normalize_legacy_vector_size()

void Slic3r::anonymous_namespace{PrintConfig.cpp}::log_normalize_legacy_vector_size ( const char * fn,
const std::string & key,
int stride,
size_t src_size,
size_t dest_size,
size_t expected_size,
size_t restore_n,
int cur_variant_count,
int target_variant_count,
size_t cur_ids,
size_t target_ids,
const ConfigOption * opt_src,
const ConfigOption * opt_target )
static
12159{
12160 BOOST_LOG_TRIVIAL(debug) << fn << ": normalizing legacy vector size for key '" << key << "'"
12161 << " stride=" << stride << " src_size=" << src_size << " dest_size=" << dest_size << " expected=" << expected_size
12162 << " restore_index.size=" << restore_n << " cur_variants=" << cur_variant_count << " target_variants=" << target_variant_count
12163 << " cur_ids=" << cur_ids << " target_ids=" << target_ids << " cur_value=" << opt_src->serialize()
12164 << " target_value=" << opt_target->serialize();
12165}
virtual std::string serialize() const =0

References log_normalize_legacy_vector_size(), and Slic3r::ConfigOption::serialize().

Referenced by log_normalize_legacy_vector_size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ looks_like_bed_exclusion_volume_syntax()

bool Slic3r::anonymous_namespace{PrintConfig.cpp}::looks_like_bed_exclusion_volume_syntax ( const std::string & value)
static
13888{
13889 return value.find('|') != std::string::npos || (value.find("..") != std::string::npos && value.find(';') != std::string::npos);
13890}

References looks_like_bed_exclusion_volume_syntax().

Referenced by looks_like_bed_exclusion_volume_syntax().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ normalize_stride2_floats()

void Slic3r::anonymous_namespace{PrintConfig.cpp}::normalize_stride2_floats ( ConfigOptionFloats & opt,
size_t expected_size )
static
12117{
12118 auto &v = opt.values;
12119 if (expected_size == 0) {
12120 v.clear();
12121 return;
12122 }
12123 if (v.empty()) {
12124 // Fallback: keep behavior predictable instead of crashing. This should be rare.
12125 v.resize(expected_size, 0.0);
12126 return;
12127 }
12128
12129 const double first = v[0];
12130 const double second = (v.size() >= 2) ? v[1] : first;
12131
12132 // Ensure we have at least one (normal,silent) pair to replicate.
12133 if (v.size() < 2) {
12134 v.resize(2, first);
12135 v[1] = second;
12136 }
12137 // Keep pair alignment if some legacy preset produced odd length.
12138 if (v.size() % 2 != 0)
12139 v.push_back(second);
12140
12141 if (v.size() > expected_size) {
12142 v.resize(expected_size);
12143 return;
12144 }
12145
12146 const size_t have_variants = v.size() / 2;
12147 const size_t want_variants = expected_size / 2;
12148 v.resize(expected_size);
12149 for (size_t vi = have_variants; vi < want_variants; ++vi) {
12150 v[vi * 2] = first;
12151 if (vi * 2 + 1 < v.size())
12152 v[vi * 2 + 1] = second;
12153 }
12154}
Definition BruteforceOptimizer.hpp:11

References normalize_stride2_floats().

Referenced by normalize_stride2_floats().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_double_token()

bool Slic3r::anonymous_namespace{PrintConfig.cpp}::parse_double_token ( const std::string & text,
double & out )
static
13893{
13894 std::string token = text;
13895 boost::trim(token);
13896 if (token.empty())
13897 return false;
13898
13899 size_t parsed = 0;
13900 out = string_to_double_decimal_point(token, &parsed);
13901 return parsed == token.size() && std::isfinite(out);
13902}
double string_to_double_decimal_point(const std::string_view str, size_t *pos)
Definition LocalesUtils.cpp:86

References parse_double_token(), and Slic3r::string_to_double_decimal_point().

Referenced by parse_double_token(), parse_exclude_polygon_points(), and parse_z_range_token().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_exclude_polygon_points()

std::optional< Polygon > Slic3r::anonymous_namespace{PrintConfig.cpp}::parse_exclude_polygon_points ( const std::string & points_str)
static
13941{
13942 Pointfs points;
13943 std::vector<std::string> point_tokens;
13944 boost::split(point_tokens, points_str, boost::is_any_of(","));
13945 points.reserve(point_tokens.size());
13946 for (std::string point_token : point_tokens) {
13947 boost::trim(point_token);
13948 const size_t separator = point_token.find('x');
13949 if (separator == std::string::npos || point_token.find('x', separator + 1) != std::string::npos)
13950 return std::nullopt;
13951
13952 double x = 0.0;
13953 double y = 0.0;
13954 if (!parse_double_token(point_token.substr(0, separator), x) ||
13955 !parse_double_token(point_token.substr(separator + 1), y) ||
13956 !std::isfinite(x) || !std::isfinite(y))
13957 return std::nullopt;
13958 points.emplace_back(x, y);
13959 }
13960 if (points.size() < 3)
13961 return std::nullopt;
13962
13963 Polygon polygon;
13964 polygon.points.reserve(points.size());
13965 for (const Vec2d &pt : points)
13966 polygon.points.emplace_back(scale_(pt.x()), scale_(pt.y()));
13967 if (polygon.area() == 0.0)
13968 return std::nullopt;
13969 polygon.make_counter_clockwise();
13970 return polygon;
13971}
static double area(const Points &pts)
Definition Polygon.cpp:65
static bool parse_double_token(const std::string &text, double &out)
Definition PrintConfig.cpp:13892
std::vector< Vec2d > Pointfs
Definition Point.hpp:77

References Slic3r::Polygon::area(), Slic3r::Polygon::make_counter_clockwise(), parse_double_token(), parse_exclude_polygon_points(), Slic3r::MultiPoint::points, and scale_.

Referenced by append_bed_exclusion_volume_regions(), and parse_exclude_polygon_points().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_master_bed_excluded_regions()

std::vector< BedExcludeRegion > Slic3r::anonymous_namespace{PrintConfig.cpp}::parse_master_bed_excluded_regions ( const Pointfs & legacy_points,
const std::string & shared_specs,
const bool use_collision_volumes,
const BedExcludeVolumeMode mode,
const double printable_height )
static
14077{
14078 std::vector<BedExcludeRegion> regions;
14079 const double height = std::max(0.0, printable_height);
14080 // Legacy excluded areas remain a shared material/placement keep-out even
14081 // when collision volumes are configured. Collision volumes add constraints;
14082 // they do not silently remove the printer profile's established area.
14083 append_legacy_bed_exclude_regions(regions, legacy_points, height);
14084 if (use_collision_volumes && mode != BedExcludeVolumeMode::PerExtruder)
14085 append_bed_exclusion_volume_regions(regions, shared_specs, height);
14086 return regions;
14087}
static void append_legacy_bed_exclude_regions(std::vector< BedExcludeRegion > &out, const Pointfs &legacy_points, const double printable_height)
Definition PrintConfig.cpp:13973
static void append_bed_exclusion_volume_regions(std::vector< BedExcludeRegion > &out, const std::string &region_specs_raw, const double printable_height)
Definition PrintConfig.cpp:13991

References append_bed_exclusion_volume_regions(), append_legacy_bed_exclude_regions(), parse_master_bed_excluded_regions(), Slic3r::PerExtruder, and Slic3r::printable_height().

Referenced by parse_master_bed_excluded_regions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_z_range_token()

bool Slic3r::anonymous_namespace{PrintConfig.cpp}::parse_z_range_token ( const std::string & token_in,
const double printable_height,
double & z_min,
double & z_max,
bool & has_z )
static
13910{
13911 std::string token = token_in;
13912 boost::trim(token);
13913 if (token.empty())
13914 return false;
13915
13916 size_t range_pos = token.find("..");
13917 if (range_pos == std::string::npos)
13918 return false;
13919
13920 std::string min_token = token.substr(0, range_pos);
13921 std::string max_token = token.substr(range_pos + 2);
13922 boost::trim(min_token);
13923 boost::trim(max_token);
13924
13925 double parsed_min = 0.0;
13926 double parsed_max = printable_height;
13927 if (! min_token.empty() && ! parse_double_token(min_token, parsed_min))
13928 return false;
13929 if (! max_token.empty() && ! parse_double_token(max_token, parsed_max))
13930 return false;
13931
13932 z_min = std::clamp(parsed_min, 0.0, printable_height);
13933 z_max = std::clamp(parsed_max, 0.0, printable_height);
13934 has_z = true;
13935 // A range wholly outside the printable height clamps to a plane, which is
13936 // not a volume and must not participate in conservative unknown-Z checks.
13937 return z_min < z_max;
13938}

References parse_double_token(), parse_z_range_token(), and Slic3r::printable_height().

Referenced by append_bed_exclusion_volume_regions(), and parse_z_range_token().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ project_bed_material_keepouts()

void Slic3r::anonymous_namespace{PrintConfig.cpp}::project_bed_material_keepouts ( std::vector< BedExcludeRegion > & regions,
const ConfigBase & cfg )
static
14090{
14091 const auto *belt = cfg.option<ConfigOptionBool>("belt_printer");
14092 if (belt == nullptr || !belt->value)
14093 return;
14094
14095 const auto *axis = cfg.option<ConfigOptionEnum<BeltRotationAxis>>("belt_slice_rotation");
14096 const auto *angle = cfg.option<ConfigOptionFloat>("belt_slice_rotation_angle");
14097 if (axis == nullptr || angle == nullptr)
14098 return;
14099
14100 const auto tilt = BeltTransformPipeline::physical_tilt(axis->value, angle->value);
14101 const double cos_x = std::cos(Geometry::deg2rad(tilt.tilt_x_deg));
14102 const double cos_y = std::cos(Geometry::deg2rad(tilt.tilt_y_deg));
14103 // Resolve bed-surface coordinates once, before any placement or tower
14104 // consumer sees them. Collision volumes already use model coordinates.
14105 for (BedExcludeRegion &region : regions)
14106 if (!region.is_collision_volume())
14107 for (Point &point : region.polygon.points)
14108 point = Point(scale_(unscale<double>(point.x()) * cos_y), scale_(unscale<double>(point.y()) * cos_x));
14109}
static PhysicalTilt physical_tilt(BeltRotationAxis axis, double angle_deg)
Definition BeltTransform.hpp:73
ConfigOption * option(const t_config_option_key &opt_key, bool create=false)
Definition Config.hpp:2768
Definition Config.hpp:1908
Definition Config.hpp:2076
Definition Config.hpp:825
Definition Point.hpp:199
constexpr T deg2rad(const T angle)
Definition Geometry.hpp:312
double angle(const Eigen::MatrixBase< Derived > &v1, const Eigen::MatrixBase< Derived2 > &v2)
Definition Point.hpp:138
T unscale(Q v)
Definition libslic3r.h:138

References Slic3r::angle(), Slic3r::Geometry::deg2rad(), Slic3r::ConfigBase::option(), Slic3r::BeltTransformPipeline::physical_tilt(), project_bed_material_keepouts(), scale_, and Slic3r::unscale().

Referenced by project_bed_material_keepouts().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resolve_bed_excluded_regions()

std::vector< BedExcludeRegion > Slic3r::anonymous_namespace{PrintConfig.cpp}::resolve_bed_excluded_regions ( const std::vector< BedExcludeRegion > & master_regions,
const BedExcludeVolumeMode mode,
const std::vector< std::string > & per_extruder_specs,
const std::vector< Vec2d > & extruder_offsets,
const size_t reference_extruder,
const size_t extruder_id,
const double printable_height )
static
14119{
14120 if (mode == BedExcludeVolumeMode::Shared)
14121 return master_regions;
14122
14124 std::vector<BedExcludeRegion> regions = master_regions;
14125 if (extruder_id < per_extruder_specs.size())
14127 regions, per_extruder_specs[extruder_id], std::max(0.0, printable_height));
14128 return regions;
14129 }
14130
14131 std::vector<BedExcludeRegion> regions = master_regions;
14132 if (extruder_id >= extruder_offsets.size() || extruder_offsets.empty())
14133 return regions;
14134
14135 const size_t clamped_reference = std::min(reference_extruder, extruder_offsets.size() - 1);
14136 // A model-space point is emitted as model_position - extruder_offset. Therefore a
14137 // carriage/toolhead obstacle described through the reference nozzle appears in another
14138 // nozzle's model space translated by (other_offset - reference_offset).
14139 const Vec2d delta = extruder_offsets[extruder_id] - extruder_offsets[clamped_reference];
14140 const Point translation(scale_(delta.x()), scale_(delta.y()));
14141 for (BedExcludeRegion &region : regions) {
14142 // Toolhead-relative offsets apply only to opt-in collision volumes.
14143 // A legacy material keep-out is bed-fixed and shared by every nozzle.
14144 if (region.is_collision_volume())
14145 region.polygon.translate(translation);
14146 }
14147 return regions;
14148}

References append_bed_exclusion_volume_regions(), Slic3r::PerExtruder, Slic3r::printable_height(), resolve_bed_excluded_regions(), scale_, and Slic3r::Shared.

Referenced by resolve_bed_excluded_regions().

Here is the call graph for this function:
Here is the caller graph for this function: