OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::arrangement Namespace Reference

Classes

class  AutoArranger
class  CircleBed
 A geometry abstraction for a circular print bed. Similarly to BoundingBox. More...
struct  InfiniteBed
 Representing an unbounded bed. More...
struct  ArrangePolygon
 Input/Output structure for the arrange() function. The poly field will not be modified during arrangement. Instead, the translation and rotation fields will mark the needed transformation for the polygon to be in the arranged position. These can also be set to an initial offset and rotation. More...
struct  ArrangeParams

Typedefs

using Item = _Item<ExPolygon>
using Box = _Box<Point>
using Circle = _Circle<Point>
using MultiPolygon = ExPolygons
using SpatElement = std::pair<Box, unsigned>
using SpatIndex = bgi::rtree< SpatElement, bgi::rstar<16, 4> >
using ItemGroup = std::vector<std::reference_wrapper<Item>>
using ArrangePolygons = std::vector<ArrangePolygon>

Functions

static bool z_ranges_overlap (double first_min, double first_max, double second_min, double second_max)
template<typename T>
static bool bed_exclusion_applies_impl (const T &item, const T &fixed_item)
bool has_bed_exclusion_regions (const ArrangePolygons &polygons)
bool bed_exclusion_applies (const ArrangePolygon &item, const ArrangePolygon &fixed_item)
void update_arrange_params (ArrangeParams &params, const DynamicPrintConfig *print_cfg, const ArrangePolygons &selected)
void update_selected_items_inflation (ArrangePolygons &selected, const DynamicPrintConfig *print_cfg, ArrangeParams &params)
void update_unselected_items_inflation (ArrangePolygons &unselected, const DynamicPrintConfig *print_cfg, const ArrangeParams &params)
void update_selected_items_axis_align (ArrangePolygons &selected, const DynamicPrintConfig *print_cfg, const ArrangeParams &params)
Points get_shrink_bedpts (const DynamicPrintConfig *print_cfg, const ArrangeParams &params)
template<class PConf>
void fill_config (PConf &pcfg, const ArrangeParams &params)
static double fixed_overfit (const std::tuple< double, Box > &result, const Box &binbb)
static double fixed_overfit_topright_sliding (const std::tuple< double, Box > &result, const Box &binbb, const std::vector< Box > &excluded_boxes)
template<class Bin>
void remove_large_items (std::vector< Item > &items, Bin &&bin)
template<class S>
Radians min_area_boundingbox_rotation (const S &sh)
template<class S>
Radians fit_into_box_rotation (const S &sh, const _Box< TPoint< S > > &box)
template<class BinT>
void _arrange (std::vector< Item > &shapes, std::vector< Item > &excludes, const BinT &bin, const ArrangeParams &params, std::function< void(unsigned, std::string)> progressfn, std::function< bool()> stopfn)
Box to_nestbin (const BoundingBox &bb)
Circle to_nestbin (const CircleBed &c)
ExPolygon to_nestbin (const Polygon &p)
Box to_nestbin (const InfiniteBed &bed)
coord_t width (const BoundingBox &box)
coord_t height (const BoundingBox &box)
double area (const BoundingBox &box)
double poly_area (const Points &pts)
double distance_to (const Point &p1, const Point &p2)
static CircleBed to_circle (const Point &center, const Points &points)
static void process_arrangeable (const ArrangePolygon &arrpoly, std::vector< Item > &outp)
template<class Fn>
auto call_with_bed (const Points &bed, Fn &&fn)
template<>
void arrange (ArrangePolygons &items, const ArrangePolygons &excludes, const Points &bed, const ArrangeParams &params)
template<class BedT>
void arrange (ArrangePolygons &arrangables, const ArrangePolygons &excludes, const BedT &bed, const ArrangeParams &params)
template void arrange (ArrangePolygons &items, const ArrangePolygons &excludes, const BoundingBox &bed, const ArrangeParams &params)
template void arrange (ArrangePolygons &items, const ArrangePolygons &excludes, const CircleBed &bed, const ArrangeParams &params)
template void arrange (ArrangePolygons &items, const ArrangePolygons &excludes, const Polygon &bed, const ArrangeParams &params)
template void arrange (ArrangePolygons &items, const ArrangePolygons &excludes, const InfiniteBed &bed, const ArrangeParams &params)
template<class TBed>
void arrange (ArrangePolygons &items, const ArrangePolygons &excludes, const TBed &bed, const ArrangeParams &params={})
 Arranges the input polygons.
template<>
void arrange (ArrangePolygons &items, const ArrangePolygons &excludes, const Points &bed, const ArrangeParams &params)
void arrange (ArrangePolygons &items, const Points &bed, const ArrangeParams &params={})
void arrange (ArrangePolygons &items, const BoundingBox &bed, const ArrangeParams &params={})
void arrange (ArrangePolygons &items, const CircleBed &bed, const ArrangeParams &params={})
void arrange (ArrangePolygons &items, const Polygon &bed, const ArrangeParams &params={})
void arrange (ArrangePolygons &items, const InfiniteBed &bed, const ArrangeParams &params={})

Variables

const double BIG_ITEM_TRESHOLD = 0.02
static const constexpr int UNARRANGED = -1
 A logical bed representing an object not being arranged. Either the arrange has not yet successfully run on this ArrangePolygon or it could not fit the object due to overly large size or invalid geometry.

Typedef Documentation

◆ ArrangePolygons

◆ Box

◆ Circle

◆ Item

◆ ItemGroup

using Slic3r::arrangement::ItemGroup = std::vector<std::reference_wrapper<Item>>

◆ MultiPolygon

◆ SpatElement

using Slic3r::arrangement::SpatElement = std::pair<Box, unsigned>

◆ SpatIndex

using Slic3r::arrangement::SpatIndex = bgi::rtree< SpatElement, bgi::rstar<16, 4> >

Function Documentation

◆ _arrange()

template<class BinT>
void Slic3r::arrangement::_arrange ( std::vector< Item > & shapes,
std::vector< Item > & excludes,
const BinT & bin,
const ArrangeParams & params,
std::function< void(unsigned, std::string)> progressfn,
std::function< bool()> stopfn )
1132{
1133 // Integer ceiling the min distance from the bed perimeters
1134 coord_t md = params.min_obj_distance;
1135 md = md / 2;
1136
1137 auto corrected_bin = bin;
1138 //sl::offset(corrected_bin, md);
1139 ArrangeParams mod_params = params;
1140 mod_params.min_obj_distance = 0; // items are already inflated
1141
1142 AutoArranger<BinT> arranger{corrected_bin, mod_params, progressfn, stopfn};
1143
1144 remove_large_items(excludes, corrected_bin);
1145
1146 // If there is something on the plate
1147 if (!excludes.empty()) arranger.preload(excludes);
1148
1149 std::vector<std::reference_wrapper<Item>> inp;
1150 inp.reserve(shapes.size() + excludes.size());
1151 for (auto &itm : shapes ) inp.emplace_back(itm);
1152 for (auto &itm : excludes) inp.emplace_back(itm);
1153
1154 // Use the minimum bounding box rotation as a starting point.
1155 // TODO: This only works for convex hull. If we ever switch to concave
1156 // polygon nesting, a convex hull needs to be calculated.
1157 if (params.allow_rotations) {
1158 for (auto &itm : shapes) {
1159 itm.rotation(min_area_boundingbox_rotation(itm.transformedShape()));
1160
1161 // If the item is too big, try to find a rotation that makes it fit
1162 if constexpr (std::is_same_v<BinT, Box>) {
1163 auto bb = itm.boundingBox();
1164 if (bb.width() >= bin.width() || bb.height() >= bin.height())
1165 itm.rotate(fit_into_box_rotation(itm.transformedShape(), bin));
1166 }
1167 }
1168 }
1169
1170 arranger(inp.begin(), inp.end());
1171 for (Item &itm : inp) itm.inflation(0);
1172}
Definition Arrange.cpp:455
void preload(std::vector< Item > &fixeditems)
Definition Arrange.cpp:995
int64_t coord_t
Definition libslic3r.h:48
Radians min_area_boundingbox_rotation(const S &sh)
Definition Arrange.cpp:1105
_Item< ExPolygon > Item
Definition Arrange.cpp:93
void remove_large_items(std::vector< Item > &items, Bin &&bin)
Definition Arrange.cpp:1092
Radians fit_into_box_rotation(const S &sh, const _Box< TPoint< S > > &box)
Definition Arrange.cpp:1119
Definition Arrange.hpp:128
coord_t min_obj_distance
The minimum distance which is allowed for any pair of items on the print bed in any direction.
Definition Arrange.hpp:132
bool allow_rotations
Definition Arrange.hpp:141

References _arrange(), Slic3r::arrangement::ArrangeParams::allow_rotations, fit_into_box_rotation(), min_area_boundingbox_rotation(), Slic3r::arrangement::ArrangeParams::min_obj_distance, Slic3r::arrangement::AutoArranger< TBin >::preload(), and remove_large_items().

Referenced by _arrange(), and arrange().

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

◆ area()

double Slic3r::arrangement::area ( const BoundingBox & box)
inline
1186{ return double(width(box)) * height(box); }
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185

References height(), and width().

Here is the call graph for this function:

◆ arrange() [1/13]

template<class BedT>
void Slic3r::arrangement::arrange ( ArrangePolygons & arrangables,
const ArrangePolygons & excludes,
const BedT & bed,
const ArrangeParams & params )
1295{
1296 std::vector<Item> items, fixeditems;
1297 items.reserve(arrangables.size());
1298
1299 for (ArrangePolygon &arrangeable : arrangables)
1300 process_arrangeable(arrangeable, items);
1301
1302 for (const ArrangePolygon &fixed: excludes)
1303 process_arrangeable(fixed, fixeditems);
1304
1305 for (Item &itm : fixeditems) itm.inflate(scaled(-2. * EPSILON));
1306
1307 _arrange(items, fixeditems, to_nestbin(bed), params, params.progressind, params.stopcondition);
1308
1309 for(size_t i = 0; i < items.size(); ++i) {
1310 Point tr = items[i].translation();
1311 arrangables[i].translation = {coord_t(tr.x()), coord_t(tr.y())};
1312 arrangables[i].rotation = items[i].rotation();
1313 arrangables[i].bed_idx = items[i].binId();
1314 arrangables[i].itemid = items[i].itemId(); // arrange order is useful for sequential printing
1315 }
1316}
#define EPSILON
Definition ColorUtils.cpp:64
Definition Point.hpp:199
Box to_nestbin(const BoundingBox &bb)
Definition Arrange.cpp:1174
void _arrange(std::vector< Item > &shapes, std::vector< Item > &excludes, const BinT &bin, const ArrangeParams &params, std::function< void(unsigned, std::string)> progressfn, std::function< bool()> stopfn)
Definition Arrange.cpp:1125
static void process_arrangeable(const ArrangePolygon &arrpoly, std::vector< Item > &outp)
Definition Arrange.cpp:1221
BoundingBox scaled(const BoundingBoxf &bb)
Definition BoundingBox.hpp:284
std::function< bool(void)> stopcondition
A predicate returning true if abort is needed.
Definition Arrange.hpp:180
std::function< void(unsigned, std::string)> progressind
Progress indicator callback called when an object gets packed. The unsigned argument is the number of...
Definition Arrange.hpp:173
Input/Output structure for the arrange() function. The poly field will not be modified during arrange...
Definition Arrange.hpp:58

References _arrange(), EPSILON, process_arrangeable(), Slic3r::arrangement::ArrangeParams::progressind, Slic3r::scaled(), Slic3r::arrangement::ArrangeParams::stopcondition, and to_nestbin().

Here is the call graph for this function:

◆ arrange() [2/13]

template void Slic3r::arrangement::arrange ( ArrangePolygons & items,
const ArrangePolygons & excludes,
const BoundingBox & bed,
const ArrangeParams & params )

◆ arrange() [3/13]

template void Slic3r::arrangement::arrange ( ArrangePolygons & items,
const ArrangePolygons & excludes,
const CircleBed & bed,
const ArrangeParams & params )

◆ arrange() [4/13]

template void Slic3r::arrangement::arrange ( ArrangePolygons & items,
const ArrangePolygons & excludes,
const InfiniteBed & bed,
const ArrangeParams & params )

◆ arrange() [5/13]

template<>
void Slic3r::arrangement::arrange ( ArrangePolygons & items,
const ArrangePolygons & excludes,
const Points & bed,
const ArrangeParams & params )
1284{
1285 call_with_bed(bed, [&](const auto &bin) {
1286 arrange(items, excludes, bin, params);
1287 });
1288}
auto call_with_bed(const Points &bed, Fn &&fn)
Definition Arrange.cpp:1259
void arrange(ArrangePolygons &items, const ArrangePolygons &excludes, const Points &bed, const ArrangeParams &params)
Definition Arrange.cpp:1280

References Slic3r::Geometry::arrange(), and call_with_bed().

Referenced by Slic3r::GUI::Plater::_calib_pa_pattern(), Slic3r::arrange_objects(), Slic3r::duplicate(), Slic3r::GUI::Plater::find_new_position(), Slic3r::ImexArranger::finish(), Slic3r::GUI::ArrangeJob::process(), Slic3r::GUI::FillBedJob::process(), and Slic3r::CLI::run().

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

◆ arrange() [6/13]

template<>
void Slic3r::arrangement::arrange ( ArrangePolygons & items,
const ArrangePolygons & excludes,
const Points & bed,
const ArrangeParams & params )
1284{
1285 call_with_bed(bed, [&](const auto &bin) {
1286 arrange(items, excludes, bin, params);
1287 });
1288}

References Slic3r::Geometry::arrange(), and call_with_bed().

Referenced by Slic3r::GUI::Plater::_calib_pa_pattern(), Slic3r::arrange_objects(), Slic3r::duplicate(), Slic3r::GUI::Plater::find_new_position(), Slic3r::ImexArranger::finish(), Slic3r::GUI::ArrangeJob::process(), Slic3r::GUI::FillBedJob::process(), and Slic3r::CLI::run().

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

◆ arrange() [7/13]

template void Slic3r::arrangement::arrange ( ArrangePolygons & items,
const ArrangePolygons & excludes,
const Polygon & bed,
const ArrangeParams & params )

◆ arrange() [8/13]

template<class TBed>
void Slic3r::arrangement::arrange ( ArrangePolygons & items,
const ArrangePolygons & excludes,
const TBed & bed,
const ArrangeParams & params = {} )

Arranges the input polygons.

WARNING: Currently, only convex polygons are supported by the libnest2d library which is used to do the arrangement. This might change in the future this is why the interface contains a general polygon capable to have holes.

Parameters
itemsInput vector of ArrangePolygons. The transformation, rotation and bin_idx fields will be changed after the call finished and can be used to apply the result on the input polygon.

◆ arrange() [9/13]

void Slic3r::arrangement::arrange ( ArrangePolygons & items,
const BoundingBox & bed,
const ArrangeParams & params = {} )
inline
242{}) { arrange(items, {}, bed, params); }

◆ arrange() [10/13]

void Slic3r::arrangement::arrange ( ArrangePolygons & items,
const CircleBed & bed,
const ArrangeParams & params = {} )
inline
243{}) { arrange(items, {}, bed, params); }

◆ arrange() [11/13]

void Slic3r::arrangement::arrange ( ArrangePolygons & items,
const InfiniteBed & bed,
const ArrangeParams & params = {} )
inline
245{}) { arrange(items, {}, bed, params); }

◆ arrange() [12/13]

void Slic3r::arrangement::arrange ( ArrangePolygons & items,
const Points & bed,
const ArrangeParams & params = {} )
inline
241{}) { arrange(items, {}, bed, params); }

◆ arrange() [13/13]

void Slic3r::arrangement::arrange ( ArrangePolygons & items,
const Polygon & bed,
const ArrangeParams & params = {} )
inline
244{}) { arrange(items, {}, bed, params); }

◆ bed_exclusion_applies()

bool Slic3r::arrangement::bed_exclusion_applies ( const ArrangePolygon & item,
const ArrangePolygon & fixed_item )
144{
145 return bed_exclusion_applies_impl(item, fixed_item);
146}
static bool bed_exclusion_applies_impl(const T &item, const T &fixed_item)
Definition Arrange.cpp:121

References bed_exclusion_applies_impl().

Here is the call graph for this function:

◆ bed_exclusion_applies_impl()

template<typename T>
bool Slic3r::arrangement::bed_exclusion_applies_impl ( const T & item,
const T & fixed_item )
static
122{
123 if (!fixed_item.is_bed_exclusion)
124 return false;
125 if (item.has_z_range && fixed_item.has_z_range &&
126 !z_ranges_overlap(item.z_min, item.z_max, fixed_item.z_min, fixed_item.z_max))
127 return false;
128
129 // Shared volumes and unresolved object mappings apply conservatively to
130 // every nozzle. Otherwise only the owning physical nozzle participates.
131 return fixed_item.bed_exclusion_extruder_id < 0 || item.bed_exclusion_extruder_ids.empty() ||
132 std::find(item.bed_exclusion_extruder_ids.begin(), item.bed_exclusion_extruder_ids.end(),
133 fixed_item.bed_exclusion_extruder_id) != item.bed_exclusion_extruder_ids.end();
134}
static bool z_ranges_overlap(double first_min, double first_max, double second_min, double second_max)
Definition Arrange.cpp:108

References z_ranges_overlap().

Referenced by bed_exclusion_applies(), and fill_config().

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

◆ call_with_bed()

template<class Fn>
auto Slic3r::arrangement::call_with_bed ( const Points & bed,
Fn && fn )
1260{
1261 if (bed.empty())
1262 return fn(InfiniteBed{});
1263 else if (bed.size() == 1)
1264 return fn(InfiniteBed{bed.front()});
1265 else {
1266 auto bb = BoundingBox(bed);
1267 CircleBed circ = to_circle(bb.center(), bed);
1268 auto parea = poly_area(bed);
1269
1270 if ((1.0 - parea / area(bb)) < 1e-3)
1271 return fn(bb);
1272 else if (!std::isnan(circ.radius()))
1273 return fn(circ);
1274 else
1275 return fn(Polygon(bed));
1276 }
1277}
double area(const BoundingBox &box)
Definition Arrange.cpp:1186
double poly_area(const Points &pts)
Definition Arrange.cpp:1187
static CircleBed to_circle(const Point &center, const Points &points)
Definition Arrange.cpp:1195
Representing an unbounded bed.
Definition Arrange.hpp:39

References Slic3r::area(), call_with_bed(), poly_area(), Slic3r::arrangement::CircleBed::radius(), and to_circle().

Referenced by arrange(), and call_with_bed().

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

◆ distance_to()

double Slic3r::arrangement::distance_to ( const Point & p1,
const Point & p2 )
inline
1189{
1190 double dx = p2.x() - p1.x();
1191 double dy = p2.y() - p1.y();
1192 return std::sqrt(dx*dx + dy*dy);
1193}

References distance_to().

Referenced by distance_to(), and to_circle().

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

◆ fill_config()

template<class PConf>
void Slic3r::arrangement::fill_config ( PConf & pcfg,
const ArrangeParams & params )
356 {
357
358 if (params.is_belt) {
359 // Pack from the end of the belt that prints first.
360 pcfg.starting_point = !params.belt_reversed ? PConf::Alignment::BOTTOM_LEFT :
361 params.belt_axis == 1 ? PConf::Alignment::TOP_LEFT :
362 PConf::Alignment::BOTTOM_RIGHT;
363 }
364 else if (params.is_seq_print) {
365 // Start placing the items from the center of the print bed
366 pcfg.starting_point = PConf::Alignment::BOTTOM_LEFT;
367 }
368 else {
369 // Start placing the items from the center of the print bed
370 pcfg.starting_point = PConf::Alignment::TOP_RIGHT;
371 }
372
373 if (params.do_final_align) {
374 // Align the arranged pile into the center of the bin
375 pcfg.alignment = PConf::Alignment::CENTER;
376 }else
377 pcfg.alignment = PConf::Alignment::DONT_ALIGN;
378
379
380 // Try 4 angles (45 degree step) and find the one with min cost
381 if (params.allow_rotations)
382 pcfg.rotations = {0., PI / 4., PI/2, 3. * PI / 4. };
383 else
384 pcfg.rotations = {0.};
385
386 // The accuracy of optimization.
387 // Goes from 0.0 to 1.0 and scales performance as well
388 pcfg.accuracy = params.accuracy;
389
390 // Allow parallel execution.
391 pcfg.parallel = params.parallel;
392
393 pcfg.should_check_collision = [](const Item &candidate, const Item &packed) {
394 if (packed.is_bed_exclusion)
395 return bed_exclusion_applies_impl(candidate, packed);
396 if (candidate.is_bed_exclusion)
397 return bed_exclusion_applies_impl(packed, candidate);
398 return true;
399 };
400
401 // BBS: excluded regions in BBS bed
402 for (auto& poly : params.excluded_regions)
403 process_arrangeable(poly, pcfg.m_excluded_regions);
404 // BBS: nonprefered regions in BBS bed
405 for (auto& poly : params.nonprefered_regions)
406 process_arrangeable(poly, pcfg.m_nonprefered_regions);
407 for (auto& itm : pcfg.m_excluded_regions) {
408 itm.markAsFixedInBin(0);
409 itm.inflate(scaled(-2. * EPSILON));
410 }
411}
static constexpr double PI
Definition libslic3r.h:81
ArrangePolygons excluded_regions
Definition Arrange.hpp:168
bool belt_reversed
Definition Arrange.hpp:165
int belt_axis
Definition Arrange.hpp:164
ArrangePolygons nonprefered_regions
Definition Arrange.hpp:169
bool is_seq_print
Definition Arrange.hpp:148
bool do_final_align
Definition Arrange.hpp:143
float accuracy
The accuracy of optimization. Goes from 0.0 to 1.0 and scales performance as well.
Definition Arrange.hpp:136
bool is_belt
Definition Arrange.hpp:163
bool parallel
Allow parallel execution.
Definition Arrange.hpp:139

References Slic3r::arrangement::ArrangeParams::accuracy, Slic3r::arrangement::ArrangeParams::allow_rotations, bed_exclusion_applies_impl(), Slic3r::arrangement::ArrangeParams::belt_axis, Slic3r::arrangement::ArrangeParams::belt_reversed, Slic3r::arrangement::ArrangeParams::do_final_align, EPSILON, Slic3r::arrangement::ArrangeParams::excluded_regions, fill_config(), Slic3r::arrangement::ArrangeParams::is_belt, Slic3r::arrangement::ArrangeParams::is_seq_print, Slic3r::arrangement::ArrangeParams::nonprefered_regions, Slic3r::arrangement::ArrangeParams::parallel, PI, process_arrangeable(), and Slic3r::scaled().

Referenced by Slic3r::arrangement::AutoArranger< TBin >::AutoArranger(), and fill_config().

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

◆ fit_into_box_rotation()

template<class S>
Radians Slic3r::arrangement::fit_into_box_rotation ( const S & sh,
const _Box< TPoint< S > > & box )
1120{
1121 return fitIntoBoxRotation<S, TCompute<S>, boost::rational<LargeInt>>(sh, box);
1122}

References fit_into_box_rotation().

Referenced by _arrange(), and fit_into_box_rotation().

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

◆ fixed_overfit()

double Slic3r::arrangement::fixed_overfit ( const std::tuple< double, Box > & result,
const Box & binbb )
static
417{
418 double score = std::get<0>(result);
419 Box pilebb = std::get<1>(result);
420 Box fullbb = sl::boundingBox(pilebb, binbb);
421 auto diff = double(fullbb.area()) - binbb.area();
422 if(diff > 0) score += diff;
423
424 return score;
425}
_Box< Point > Box
Definition Arrange.cpp:94
Slic3r::Polygons diff(const Slic3r::Polygon &subject, const Slic3r::Polygon &clip, ApplySafetyOffset do_safety_offset)
Definition ClipperUtils.cpp:731

References Slic3r::diff(), and fixed_overfit().

Referenced by Slic3r::arrangement::AutoArranger< TBin >::AutoArranger(), and fixed_overfit().

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

◆ fixed_overfit_topright_sliding()

double Slic3r::arrangement::fixed_overfit_topright_sliding ( const std::tuple< double, Box > & result,
const Box & binbb,
const std::vector< Box > & excluded_boxes )
static
429{
430 double score = std::get<0>(result);
431 Box pilebb = std::get<1>(result);
432
433 auto shift = binbb.maxCorner() - pilebb.maxCorner();
434 shift.x() = std::max((coord_t)0, shift.x()); // do not allow left shift
435 shift.y() = std::max((coord_t)0, shift.y()); // do not allow bottom shift
436 pilebb.minCorner() += shift;
437 pilebb.maxCorner() += shift;
438
439 Box fullbb = sl::boundingBox(pilebb, binbb);
440 auto diff = double(fullbb.area()) - binbb.area();
441 if (diff > 0) score += diff;
442
443 // excluded regions and nonprefered regions should not intersect the translated pilebb
444 for (auto &bb : excluded_boxes) {
445 auto area_ = pilebb.intersection(bb).area();
446 if (area_ > 0) score += area_;
447 }
448
449 return score;
450}

References Slic3r::diff(), and fixed_overfit_topright_sliding().

Referenced by fixed_overfit_topright_sliding().

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

◆ get_shrink_bedpts()

Points Slic3r::arrangement::get_shrink_bedpts ( const DynamicPrintConfig * print_cfg,
const ArrangeParams & params )
340{
341 Points bedpts = get_bed_shape(*print_cfg);
342 // shrink bed by moving to center by dist
343 auto shrinkFun = [](Points& bedpts, double dist, int direction) {
344#define SGN(x) ((x) >= 0 ? 1 : -1)
345 Point center = Polygon(bedpts).bounding_box().center();
346 for (auto& pt : bedpts) pt[direction] += dist * SGN(center[direction] - pt[direction]);
347 };
348 shrinkFun(bedpts, scaled(params.bed_shrink_x), 0);
349 shrinkFun(bedpts, scaled(params.bed_shrink_y), 1);
350 return bedpts;
351}
#define SGN(x)
PointType center() const
Definition BoundingBox.cpp:228
BoundingBox bounding_box() const
Definition MultiPoint.cpp:100
Definition Polygon.hpp:31
T dist(const boost::polygon::point_data< T > &p1, const boost::polygon::point_data< T > &p2)
Definition Geometry.cpp:298
void center(ExPolygonsWithIds &e)
Definition Emboss.cpp:1382
std::vector< Point, PointsAllocator< Point > > Points
Definition Point.hpp:73
Points get_bed_shape(const DynamicPrintConfig &config, bool use_share)
Definition PrintConfig.cpp:13837
float bed_shrink_y
Definition Arrange.hpp:151
float bed_shrink_x
Definition Arrange.hpp:150

References Slic3r::arrangement::ArrangeParams::bed_shrink_x, Slic3r::arrangement::ArrangeParams::bed_shrink_y, Slic3r::MultiPoint::bounding_box(), Slic3r::BoundingBoxBase< PointType, APointsType >::center(), Slic3r::center(), Slic3r::Geometry::dist(), Slic3r::get_bed_shape(), get_shrink_bedpts(), Slic3r::scaled(), and SGN.

Referenced by Slic3r::GUI::Plater::_calib_pa_pattern(), and get_shrink_bedpts().

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

◆ has_bed_exclusion_regions()

bool Slic3r::arrangement::has_bed_exclusion_regions ( const ArrangePolygons & polygons)
137{
138 return std::any_of(polygons.begin(), polygons.end(), [](const ArrangePolygon &polygon) {
139 return polygon.is_bed_exclusion;
140 });
141}

◆ height()

coord_t Slic3r::arrangement::height ( const BoundingBox & box)
inline
1185{ return box.max.y() - box.min.y(); }
PointType max
Definition BoundingBox.hpp:21
PointType min
Definition BoundingBox.hpp:20

References height(), Slic3r::BoundingBoxBase< PointType, APointsType >::max, and Slic3r::BoundingBoxBase< PointType, APointsType >::min.

Referenced by area(), and height().

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

◆ min_area_boundingbox_rotation()

template<class S>
Radians Slic3r::arrangement::min_area_boundingbox_rotation ( const S & sh)
1106{
1107 try {
1108 return minAreaBoundingBox<S, TCompute<S>, boost::rational<LargeInt>>(sh)
1109 .angleToX();
1110 }
1111 catch (const std::exception& e) {
1112 // min_area_boundingbox_rotation may throw exception of dividing 0 if the object is already perfectly aligned to X
1113 BOOST_LOG_TRIVIAL(error) << "arranging min_area_boundingbox_rotation fails, msg=" << e.what();
1114 return 0.0;
1115 }
1116}

References min_area_boundingbox_rotation().

Referenced by _arrange(), and min_area_boundingbox_rotation().

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

◆ poly_area()

double Slic3r::arrangement::poly_area ( const Points & pts)
inline
1187{ return std::abs(Polygon::area(pts)); }
static double area(const Points &pts)
Definition Polygon.cpp:65

References Slic3r::Polygon::area(), and poly_area().

Referenced by call_with_bed(), and poly_area().

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

◆ process_arrangeable()

void Slic3r::arrangement::process_arrangeable ( const ArrangePolygon & arrpoly,
std::vector< Item > & outp )
static
1223{
1224 Polygon p = arrpoly.poly.contour;
1225 const Vec2crd &offs = arrpoly.translation;
1226 double rotation = arrpoly.rotation;
1227
1228 if (p.is_counter_clockwise()) p.reverse();
1229
1230 if (p.size() < 3)
1231 return;
1232
1233 outp.emplace_back(std::move(p));
1234 Item& item = outp.back();
1235 item.rotation(rotation);
1236 item.translation({offs.x(), offs.y()});
1237 item.binId(arrpoly.bed_idx);
1238 item.priority(arrpoly.priority);
1239 item.itemId(arrpoly.itemid);
1240 item.extrude_ids = arrpoly.extrude_ids;
1241 item.height = arrpoly.height;
1242 item.z_min = arrpoly.z_min;
1243 item.z_max = arrpoly.z_max;
1244 item.has_z_range = arrpoly.has_z_range;
1245 item.is_bed_exclusion = arrpoly.is_bed_exclusion;
1246 item.bed_exclusion_extruder_ids = arrpoly.bed_exclusion_extruder_ids;
1247 item.bed_exclusion_extruder_id = arrpoly.bed_exclusion_extruder_id;
1248 item.name = arrpoly.name;
1249 //BBS: add virtual object logic
1250 item.is_virt_object = arrpoly.is_virt_object;
1251 item.is_wipe_tower = arrpoly.is_wipe_tower;
1252 item.bed_temp = arrpoly.first_bed_temp;
1253 item.print_temp = arrpoly.print_temp;
1254 item.vitrify_temp = arrpoly.vitrify_temp;
1255 item.inflation(arrpoly.inflation);
1256 item.filament_temp_type = arrpoly.filament_temp_type;
1257}
Polygon contour
Definition ExPolygon.hpp:42
void reverse()
Definition MultiPoint.hpp:43
size_t size() const
Definition MultiPoint.hpp:50
bool is_counter_clockwise() const
Definition Polygon.cpp:84
Eigen::Matrix< coord_t, 2, 1, Eigen::DontAlign > Vec2crd
Definition Point.hpp:52
double height
Definition Arrange.hpp:83
bool is_wipe_tower
Definition Arrange.hpp:69
ExPolygon poly
Definition Arrange.hpp:59
std::vector< int > extrude_ids
Definition Arrange.hpp:74
int vitrify_temp
first layer print temperature for different material judge
Definition Arrange.hpp:80
int filament_temp_type
extruder_id for least extruder switch
Definition Arrange.hpp:75
int itemid
Definition Arrange.hpp:81
Vec2crd translation
The 2D silhouette to be arranged.
Definition Arrange.hpp:60
int bed_exclusion_extruder_id
Definition Arrange.hpp:94
double z_min
Definition Arrange.hpp:84
std::vector< int > bed_exclusion_extruder_ids
Definition Arrange.hpp:92
int first_bed_temp
print temperature for different material judge
Definition Arrange.hpp:78
int print_temp
bed temperature for different material judge
Definition Arrange.hpp:77
double rotation
The translation of the poly.
Definition Arrange.hpp:61
int priority
To which logical bed does poly belong...
Definition Arrange.hpp:64
bool is_bed_exclusion
Definition Arrange.hpp:87
bool is_virt_object
Definition Arrange.hpp:67
coord_t inflation
The rotation of the poly in radians.
Definition Arrange.hpp:62
bool has_z_range
Definition Arrange.hpp:86
double z_max
Definition Arrange.hpp:85
std::string name
Definition Arrange.hpp:96
int bed_idx
Arrange with inflated polygon.
Definition Arrange.hpp:63

References Slic3r::arrangement::ArrangePolygon::bed_exclusion_extruder_id, Slic3r::arrangement::ArrangePolygon::bed_exclusion_extruder_ids, Slic3r::arrangement::ArrangePolygon::bed_idx, Slic3r::ExPolygon::contour, Slic3r::arrangement::ArrangePolygon::extrude_ids, Slic3r::arrangement::ArrangePolygon::filament_temp_type, Slic3r::arrangement::ArrangePolygon::first_bed_temp, Slic3r::arrangement::ArrangePolygon::has_z_range, Slic3r::arrangement::ArrangePolygon::height, Slic3r::arrangement::ArrangePolygon::inflation, Slic3r::arrangement::ArrangePolygon::is_bed_exclusion, Slic3r::Polygon::is_counter_clockwise(), Slic3r::arrangement::ArrangePolygon::is_virt_object, Slic3r::arrangement::ArrangePolygon::is_wipe_tower, Slic3r::arrangement::ArrangePolygon::itemid, Slic3r::arrangement::ArrangePolygon::name, Slic3r::arrangement::ArrangePolygon::poly, Slic3r::arrangement::ArrangePolygon::print_temp, Slic3r::arrangement::ArrangePolygon::priority, process_arrangeable(), Slic3r::MultiPoint::reverse(), Slic3r::arrangement::ArrangePolygon::rotation, Slic3r::MultiPoint::size(), Slic3r::arrangement::ArrangePolygon::translation, Slic3r::arrangement::ArrangePolygon::vitrify_temp, Slic3r::arrangement::ArrangePolygon::z_max, and Slic3r::arrangement::ArrangePolygon::z_min.

Referenced by arrange(), fill_config(), and process_arrangeable().

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

◆ remove_large_items()

template<class Bin>
void Slic3r::arrangement::remove_large_items ( std::vector< Item > & items,
Bin && bin )
1093{
1094 auto it = items.begin();
1095 while (it != items.end())
1096 {
1097 //BBS: skip virtual object
1098 if (!it->is_virt_object && !sl::isInside(it->transformedShape(), bin))
1099 it = items.erase(it);
1100 else
1101 it++;
1102 }
1103}

References remove_large_items().

Referenced by _arrange(), and remove_large_items().

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

◆ to_circle()

CircleBed Slic3r::arrangement::to_circle ( const Point & center,
const Points & points )
static
1195 {
1196 std::vector<double> vertex_distances;
1197 double avg_dist = 0;
1198
1199 for (auto pt : points)
1200 {
1201 double distance = distance_to(center, pt);
1202 vertex_distances.push_back(distance);
1203 avg_dist += distance;
1204 }
1205
1206 avg_dist /= vertex_distances.size();
1207
1208 CircleBed ret(center, avg_dist);
1209 for(auto el : vertex_distances)
1210 {
1211 if (std::abs(el - avg_dist) > 10 * SCALED_EPSILON) {
1212 ret = {};
1213 break;
1214 }
1215 }
1216
1217 return ret;
1218}
A geometry abstraction for a circular print bed. Similarly to BoundingBox.
Definition Arrange.hpp:26
#define SCALED_EPSILON
Definition libslic3r.h:109
double distance_to(const Point &p1, const Point &p2)
Definition Arrange.cpp:1188

References Slic3r::center(), distance_to(), SCALED_EPSILON, and to_circle().

Referenced by call_with_bed(), and to_circle().

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

◆ to_nestbin() [1/4]

Box Slic3r::arrangement::to_nestbin ( const BoundingBox & bb)
inline
1174{ return Box{{bb.min(X), bb.min(Y)}, {bb.max(X), bb.max(Y)}};}
@ Y
Definition libslic3r.h:142
@ X
Definition libslic3r.h:141

References Slic3r::BoundingBoxBase< PointType, APointsType >::max, Slic3r::BoundingBoxBase< PointType, APointsType >::min, to_nestbin(), Slic3r::X, and Slic3r::Y.

Referenced by arrange(), to_nestbin(), to_nestbin(), to_nestbin(), and to_nestbin().

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

◆ to_nestbin() [2/4]

Circle Slic3r::arrangement::to_nestbin ( const CircleBed & c)
inline
1175{ return Circle({c.center()(0), c.center()(1)}, c.radius()); }
double radius() const
Definition Arrange.hpp:34
const Point & center() const
Definition Arrange.hpp:35
_Circle< Point > Circle
Definition Arrange.cpp:95

References Slic3r::arrangement::CircleBed::center(), Slic3r::Circle, Slic3r::arrangement::CircleBed::radius(), and to_nestbin().

Here is the call graph for this function:

◆ to_nestbin() [3/4]

Box Slic3r::arrangement::to_nestbin ( const InfiniteBed & bed)
inline
1179{
1180 const coord_t r = coord_t(1) << 50;
1181 return Box{{bed.center.x() - r, bed.center.y() - r}, {bed.center.x() + r, bed.center.y() + r}};
1182}
Point center
Definition Arrange.hpp:40

References Slic3r::arrangement::InfiniteBed::center, and to_nestbin().

Here is the call graph for this function:

◆ to_nestbin() [4/4]

ExPolygon Slic3r::arrangement::to_nestbin ( const Polygon & p)
inline
1176{ return ExPolygon{p}; }
Definition ExPolygon.hpp:23

References to_nestbin().

Here is the call graph for this function:

◆ update_arrange_params()

void Slic3r::arrangement::update_arrange_params ( ArrangeParams & params,
const DynamicPrintConfig * print_cfg,
const ArrangePolygons & selected )
149{
150 double skirt_distance = get_real_skirt_dist(*print_cfg);
151 // Note: skirt_distance is now defined between outermost brim and skirt, not the object and skirt.
152 // So we can't do max but do adding instead.
153 params.brim_skirt_distance = skirt_distance;
154 params.bed_shrink_x += params.brim_skirt_distance;
155 params.bed_shrink_y += params.brim_skirt_distance;
156 // for sequential print, we need to inflate the bed because clearance_radius is so large
157 if (params.is_seq_print) {
158 params.bed_shrink_x -= params.clearance_radius / 2;
159 params.bed_shrink_y -= params.clearance_radius / 2;
160 }
161}
float get_real_skirt_dist(const DynamicPrintConfig &cfg)
Definition PrintConfig.cpp:14413
float clearance_radius
Definition Arrange.hpp:155
float brim_skirt_distance
Definition Arrange.hpp:152

References Slic3r::arrangement::ArrangeParams::bed_shrink_x, Slic3r::arrangement::ArrangeParams::bed_shrink_y, Slic3r::arrangement::ArrangeParams::brim_skirt_distance, Slic3r::arrangement::ArrangeParams::clearance_radius, Slic3r::get_real_skirt_dist(), and Slic3r::arrangement::ArrangeParams::is_seq_print.

Referenced by Slic3r::CLI::run().

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

◆ update_selected_items_axis_align()

void Slic3r::arrangement::update_selected_items_axis_align ( ArrangePolygons & selected,
const DynamicPrintConfig * print_cfg,
const ArrangeParams & params )
235{
236 // now only need to consider "Align to x axis"
237 if (!params.align_to_y_axis)
238 return;
239
240 for (ArrangePolygon& ap : selected) {
241 bool validResult = false;
242 double angle = 0.0;
243 {
244 const auto& pts = ap.transformed_poly().contour;
245 int lpt = pts.size();
246 double a00 = 0, a10 = 0, a01 = 0, a20 = 0, a11 = 0, a02 = 0, a30 = 0, a21 = 0, a12 = 0, a03 = 0;
247 double xi, yi, xi2, yi2, xi_1, yi_1, xi_12, yi_12, dxy, xii_1, yii_1;
248 xi_1 = pts.back().x();
249 yi_1 = pts.back().y();
250
251 xi_12 = xi_1 * xi_1;
252 yi_12 = yi_1 * yi_1;
253
254 for (int i = 0; i < lpt; i++) {
255 xi = pts[i].x();
256 yi = pts[i].y();
257
258 xi2 = xi * xi;
259 yi2 = yi * yi;
260 dxy = xi_1 * yi - xi * yi_1;
261 xii_1 = xi_1 + xi;
262 yii_1 = yi_1 + yi;
263
264 a00 += dxy;
265 a10 += dxy * xii_1;
266 a01 += dxy * yii_1;
267 a20 += dxy * (xi_1 * xii_1 + xi2);
268 a11 += dxy * (xi_1 * (yii_1 + yi_1) + xi * (yii_1 + yi));
269 a02 += dxy * (yi_1 * yii_1 + yi2);
270 a30 += dxy * xii_1 * (xi_12 + xi2);
271 a03 += dxy * yii_1 * (yi_12 + yi2);
272 a21 += dxy * (xi_12 * (3 * yi_1 + yi) + 2 * xi * xi_1 * yii_1 + xi2 * (yi_1 + 3 * yi));
273 a12 += dxy * (yi_12 * (3 * xi_1 + xi) + 2 * yi * yi_1 * xii_1 + yi2 * (xi_1 + 3 * xi));
274 xi_1 = xi;
275 yi_1 = yi;
276 xi_12 = xi2;
277 yi_12 = yi2;
278 }
279
280 if (std::abs(a00) > EPSILON) {
281 double db1_2, db1_6, db1_12, db1_24, db1_20, db1_60;
282 double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03;
283 if (a00 > 0) {
284 db1_2 = 0.5;
285 db1_6 = 0.16666666666666666666666666666667;
286 db1_12 = 0.083333333333333333333333333333333;
287 db1_24 = 0.041666666666666666666666666666667;
288 db1_20 = 0.05;
289 db1_60 = 0.016666666666666666666666666666667;
290 }
291 else {
292 db1_2 = -0.5;
293 db1_6 = -0.16666666666666666666666666666667;
294 db1_12 = -0.083333333333333333333333333333333;
295 db1_24 = -0.041666666666666666666666666666667;
296 db1_20 = -0.05;
297 db1_60 = -0.016666666666666666666666666666667;
298 }
299 m00 = a00 * db1_2;
300 m10 = a10 * db1_6;
301 m01 = a01 * db1_6;
302 m20 = a20 * db1_12;
303 m11 = a11 * db1_24;
304 m02 = a02 * db1_12;
305 m30 = a30 * db1_20;
306 m21 = a21 * db1_60;
307 m12 = a12 * db1_60;
308 m03 = a03 * db1_20;
309
310 double cx = m10 / m00;
311 double cy = m01 / m00;
312
313 double a = m20 / m00 - cx * cx;
314 double b = m11 / m00 - cx * cy;
315 double c = m02 / m00 - cy * cy;
316
317 //if a and c are close, there is no dominant axis, then do not rotate
318 // ratio is always no more than 1
319 double ratio = std::abs(a) > std::abs(c) ? std::abs(c / a) :
320 std::abs(c) > 0 ? std::abs(a / c) : 0;
321 if (ratio>0.66) {
322 validResult = false;
323 }
324 else {
325 angle = std::atan2(2 * b, (a - c)) / 2;
326 angle = PI / 2 - angle;
327 // if the angle is close to PI or -PI, it means the object is vertical, then do not rotate
328 if (std::abs(std::abs(angle) - PI) < 0.01)
329 angle = 0;
330 validResult = true;
331 }
332 }
333 }
334 if (validResult) { ap.rotation += angle; }
335 }
336}
double angle(const Eigen::MatrixBase< Derived > &v1, const Eigen::MatrixBase< Derived2 > &v2)
Definition Point.hpp:138
bool align_to_y_axis
Definition Arrange.hpp:149

References Slic3r::arrangement::ArrangeParams::align_to_y_axis, Slic3r::angle(), EPSILON, PI, and update_selected_items_axis_align().

Referenced by Slic3r::CLI::run(), and update_selected_items_axis_align().

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

◆ update_selected_items_inflation()

void Slic3r::arrangement::update_selected_items_inflation ( ArrangePolygons & selected,
const DynamicPrintConfig * print_cfg,
ArrangeParams & params )
163 {
164 // do not inflate brim_width. Objects are allowed to have overlapped brim.
165 // A brim reaching the printable area's edge is fine, so measure against the full bed.
166 BoundingBox bedbb = Polygon(get_bed_shape(*print_cfg)).bounding_box();
167 // set obj distance for auto seq_print
168 if (params.is_seq_print) {
169 bool all_objects_are_short = std::all_of(selected.begin(), selected.end(), [&](ArrangePolygon& ap) { return ap.height < params.nozzle_height; });
170 if (all_objects_are_short) {
171 params.min_obj_distance = std::max(params.min_obj_distance, scaled(std::max(MAX_OUTER_NOZZLE_DIAMETER/2.f, params.object_skirt_offset*2)+0.001));
172 }
173 else
174 params.min_obj_distance = std::max(params.min_obj_distance, scaled(params.clearance_radius + 0.001)); // +0.001mm to avoid clearance check fail due to rounding error
175 }
176 double brim_max = 0;
177 bool plate_has_tree_support = false;
178 std::for_each(selected.begin(), selected.end(), [&](ArrangePolygon& ap) {
179 brim_max = std::max(brim_max, ap.brim_width);
180 if (ap.has_tree_support) plate_has_tree_support = true; });
181 std::for_each(selected.begin(), selected.end(), [&](ArrangePolygon& ap) {
182 // 1. if user input a distance, use it
183 // 2. if there is an object with tree support, all objects use the max tree branch radius (brim_max=branch diameter)
184 // 3. otherwise, use each object's own brim width
185 ap.inflation = params.min_obj_distance != 0 ? params.min_obj_distance / 2 :
186 plate_has_tree_support ? scaled(brim_max / 2) : scaled(ap.brim_width);
187 if (params.min_obj_distance != 0)
188 return; // an explicit object distance is the user's call, not ours to shrink
189 // An item cannot be larger than the printable area, inflation included. Inflating
190 // an almost bed filling item would leave it too big to ever be placed.
191 BoundingBox apbb = ap.poly.contour.bounding_box();
192 auto diffx = bedbb.size().x() - apbb.size().x();
193 auto diffy = bedbb.size().y() - apbb.size().y();
194 ap.inflation = std::max<coord_t>(0, std::min({ ap.inflation, diffx / 2, diffy / 2 }));
195 });
196
197 // Give the bed margin, which the arrange bed keeps from the printable area, back
198 // where the largest item needs it. The skirt keeps its room: pushing a skirt off
199 // the bed is worse than saying the item does not fit.
200 if (!selected.empty()) {
201 coord_t max_width = 0, max_height = 0;
202 for (const ArrangePolygon &ap : selected) {
203 BoundingBox apbb = ap.poly.contour.bounding_box();
204 max_width = std::max(max_width, apbb.size().x() + 2 * ap.inflation);
205 max_height = std::max(max_height, apbb.size().y() + 2 * ap.inflation);
206 }
207 auto margin = [](coord_t bed, coord_t item) { return std::max(0., unscale<double>(bed - item) / 2.); };
208 params.bed_shrink_x = std::min<double>(params.bed_shrink_x, std::max<double>(params.brim_skirt_distance, margin(bedbb.size().x(), max_width)));
209 params.bed_shrink_y = std::min<double>(params.bed_shrink_y, std::max<double>(params.brim_skirt_distance, margin(bedbb.size().y(), max_height)));
210 }
211}
#define MAX_OUTER_NOZZLE_DIAMETER
Definition Print.hpp:72
PointType size() const
Definition BoundingBox.cpp:178
Definition BoundingBox.hpp:212
T unscale(Q v)
Definition libslic3r.h:138
float object_skirt_offset
Definition Arrange.hpp:156

References Slic3r::MultiPoint::bounding_box(), Slic3r::arrangement::ArrangeParams::clearance_radius, Slic3r::get_bed_shape(), Slic3r::arrangement::ArrangeParams::is_seq_print, MAX_OUTER_NOZZLE_DIAMETER, Slic3r::arrangement::ArrangeParams::min_obj_distance, Slic3r::arrangement::ArrangeParams::object_skirt_offset, and Slic3r::scaled().

Referenced by Slic3r::CLI::run().

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

◆ update_unselected_items_inflation()

void Slic3r::arrangement::update_unselected_items_inflation ( ArrangePolygons & unselected,
const DynamicPrintConfig * print_cfg,
const ArrangeParams & params )
214{
215 float exclusion_gap = 1.f;
216 if (params.is_seq_print) {
217 // bed_shrink_x is typically (-params.clearance_radius / 2+5) for seq_print
218 exclusion_gap = std::max(exclusion_gap, params.clearance_radius / 2 + params.bed_shrink_x + 1.f); // +1mm gap so the exclusion region is not too close
219 // dont forget to move the excluded region
220 for (auto& region : unselected) {
221 if (region.is_virt_object) region.poly.translate(scaled(params.bed_shrink_x), scaled(params.bed_shrink_y));
222 }
223 }
224 // For occulusion regions, inflation should be larger to prevent genrating brim on them.
225 // However, extrusion cali regions are exceptional, since we can allow brim overlaps them.
226 // 屏蔽区域只需要膨胀brim宽度,防止brim长过去;挤出标定区域不需要膨胀,brim可以长过去。
227 // 以前我们认为还需要膨胀clearance_radius/2,这其实是不需要的,因为这些区域并不会真的摆放物体,
228 // 其他物体的膨胀轮廓是可以跟它们重叠的。
229 std::for_each(unselected.begin(), unselected.end(),
230 [&](auto& ap) { ap.inflation = !ap.is_virt_object ? (params.min_obj_distance == 0 ? scaled(ap.brim_width) : params.min_obj_distance / 2)
231 : (ap.is_extrusion_cali_object ? 0 : scale_(exclusion_gap)); });
232}

References Slic3r::arrangement::ArrangeParams::bed_shrink_x, Slic3r::arrangement::ArrangeParams::bed_shrink_y, Slic3r::arrangement::ArrangeParams::clearance_radius, Slic3r::arrangement::ArrangeParams::is_seq_print, Slic3r::scaled(), and update_unselected_items_inflation().

Referenced by Slic3r::CLI::run(), and update_unselected_items_inflation().

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

◆ width()

coord_t Slic3r::arrangement::width ( const BoundingBox & box)
inline
1184{ return box.max.x() - box.min.x(); }

References Slic3r::BoundingBoxBase< PointType, APointsType >::max, Slic3r::BoundingBoxBase< PointType, APointsType >::min, and width().

Referenced by area(), and width().

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

◆ z_ranges_overlap()

bool Slic3r::arrangement::z_ranges_overlap ( double first_min,
double first_max,
double second_min,
double second_max )
static
109{
110 if (first_min > first_max)
111 std::swap(first_min, first_max);
112 if (second_min > second_max)
113 std::swap(second_min, second_max);
114
115 // Touching a volume is treated as a collision. Arrangement may leave some
116 // usable space empty, but it must not create a marginally unsafe placement.
117 return first_max >= second_min - EPSILON && second_max >= first_min - EPSILON;
118}

References EPSILON.

Referenced by bed_exclusion_applies_impl().

Here is the caller graph for this function:

Variable Documentation

◆ BIG_ITEM_TRESHOLD

◆ UNARRANGED

const constexpr int Slic3r::arrangement::UNARRANGED = -1
staticconstexpr

A logical bed representing an object not being arranged. Either the arrange has not yet successfully run on this ArrangePolygon or it could not fit the object due to overly large size or invalid geometry.

Referenced by Slic3r::ImexArranger::finish(), Slic3r::arrangement::ArrangePolygon::is_arranged(), Slic3r::GUI::PartPlateList::postprocess_arrange_polygon(), and Slic3r::GUI::FillBedJob::process().