Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ doc/
test.js
/.cache/
.clangd
.idea/
16 changes: 10 additions & 6 deletions src/BambuStudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ std::map<int, std::string> cli_errors = {
{CLI_GCODE_IN_WRAPPING_DETECT_AREA, "Found G-code in the wrapping detect area. Please make sure the 3mf file can be successfully sliced in the latest Bambu Studio."}
};

namespace {
// File-scope constant to avoid lambda capture issues across compilers (MSVC vs Clang)
constexpr ForwardCompatibilitySubstitutionRule config_substitution_rule = ForwardCompatibilitySubstitutionRule::Enable;
}

typedef struct _object_info{
int id{0};
std::string name;
Expand Down Expand Up @@ -1447,9 +1452,8 @@ int CLI::run(int argc, char **argv)
std::vector<std::string> downward_settings = m_config.option<ConfigOptionStrings>("downward_settings", true)->values;
std::vector<std::string> downward_compatible_machines;
std::set<std::string> downward_uncompatible_machines;
//BBS: always use ForwardCompatibilitySubstitutionRule::Enable
//BBS: always use ForwardCompatibilitySubstitutionRule::Enable (now defined at file scope)
//const ForwardCompatibilitySubstitutionRule config_substitution_rule = m_config.option<ConfigOptionEnum<ForwardCompatibilitySubstitutionRule>>("config_compatibility", true)->value;
const ForwardCompatibilitySubstitutionRule config_substitution_rule = ForwardCompatibilitySubstitutionRule::Enable;
const std::vector<std::string> &load_filaments = m_config.option<ConfigOptionStrings>("load_filaments", true)->values;
//skip model object logic
const std::vector<int> &skip_objects = m_config.option<ConfigOptionInts>("skip_objects", true)->values;
Expand Down Expand Up @@ -2023,7 +2027,7 @@ int CLI::run(int argc, char **argv)
}
}
catch (std::exception& e) {
boost::nowide::cerr << construct_assemble_list << ": " << e.what() << std::endl;
boost::nowide::cerr << "construct_assemble_list: " << e.what() << std::endl;
record_exit_reson(outfile_dir, CLI_DATA_FILE_ERROR, 0, cli_errors[CLI_DATA_FILE_ERROR], sliced_info);
flush_and_exit(CLI_DATA_FILE_ERROR);
}
Expand Down Expand Up @@ -2087,7 +2091,7 @@ int CLI::run(int argc, char **argv)
}
}

auto load_config_file = [config_substitution_rule](const std::string& file, DynamicPrintConfig& config, std::string& config_type,
auto load_config_file = [](const std::string& file, DynamicPrintConfig& config, std::string& config_type,
std::string& config_name, std::string& filament_id, std::string& config_from) {
if (! boost::filesystem::exists(file)) {
boost::nowide::cerr << __FUNCTION__<< ": can not find setting file: " << file << std::endl;
Expand Down Expand Up @@ -4992,7 +4996,7 @@ int CLI::run(int argc, char **argv)
}
}

if (!arrange_cfg.is_seq_print && (assemble_plate.filaments_count > 1)||(enable_wrapping_detect && !current_wrapping_exclude_area.empty()))
if ((!arrange_cfg.is_seq_print && (assemble_plate.filaments_count > 1)) || (enable_wrapping_detect && !current_wrapping_exclude_area.empty()))
{
//prepare the wipe tower
int plate_count = partplate_list.get_plate_count();
Expand Down Expand Up @@ -7534,7 +7538,7 @@ int CLI::run(int argc, char **argv)
gcode_viewer.render_calibration_thumbnail(*calibration_data, cali_thumbnail_width, cali_thumbnail_height,
calibration_params, partplate_list, opengl_mgr);
//generate_calibration_thumbnail(*calibration_data, thumbnail_width, thumbnail_height, calibration_params);
//*plate_bboxes[index] = p->generate_first_layer_bbox();
*plate_bboxes[index] = p->generate_first_layer_bbox();
calibration_thumbnails.push_back(calibration_data);*/

PlateBBoxData* plate_bbox = new PlateBBoxData();
Expand Down
12 changes: 6 additions & 6 deletions src/libnest2d/include/libnest2d/optimizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class Optimizer {
{
dir_ = OptDir::MIN;
return static_cast<Subclass*>(this)->template optimize<Func, Args...>(
forward<Func>(objectfunction), initvals, bounds... );
std::forward<Func>(objectfunction), initvals, bounds... );
}

template<class Func, class...Args>
Expand All @@ -165,15 +165,15 @@ class Optimizer {
{
dir_ = OptDir::MIN;
return static_cast<Subclass*>(this)->template optimize<Func, Args...>(
forward<Func>(objectfunction), initvals, Bound<Args>()... );
std::forward<Func>(objectfunction), initvals, Bound<Args>()... );
}

template<class...Args, class Func>
inline Result<Args...> optimize_min(Func&& objectfunction)
{
dir_ = OptDir::MIN;
return static_cast<Subclass*>(this)->template optimize<Func, Args...>(
forward<Func>(objectfunction),
std::forward<Func>(objectfunction),
Input<Args...>(),
Bound<Args>()... );
}
Expand All @@ -186,7 +186,7 @@ class Optimizer {
{
dir_ = OptDir::MAX;
return static_cast<Subclass*>(this)->template optimize<Func, Args...>(
forward<Func>(objectfunction), initvals, bounds... );
std::forward<Func>(objectfunction), initvals, bounds... );
}

template<class Func, class...Args>
Expand All @@ -195,15 +195,15 @@ class Optimizer {
{
dir_ = OptDir::MAX;
return static_cast<Subclass*>(this)->template optimize<Func, Args...>(
forward<Func>(objectfunction), initvals, Bound<Args>()... );
std::forward<Func>(objectfunction), initvals, Bound<Args>()... );
}

template<class...Args, class Func>
inline Result<Args...> optimize_max(Func&& objectfunction)
{
dir_ = OptDir::MAX;
return static_cast<Subclass*>(this)->template optimize<Func, Args...>(
forward<Func>(objectfunction),
std::forward<Func>(objectfunction),
Input<Args...>(),
Bound<Args>()... );
}
Expand Down
23 changes: 8 additions & 15 deletions src/libnest2d/include/libnest2d/placers/bottomleftplacer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,21 +378,14 @@ class _BottomLeftPlacer: public PlacerBoilerplate<
// the additional vertices for maintaning min object distance
sl::reserve(rsh, finish-start+4);

auto addOthers_ = [&rsh, finish, start, &item](){
for(size_t i = start+1; i < finish; i++)
sl::addVertex(rsh, item.vertex(i));
};

auto reverseAddOthers_ = [&rsh, finish, start, &item](){
for(auto i = finish-1; i > start; i--)
sl::addVertex(rsh, item.vertex(static_cast<unsigned long>(i)));
};

auto addOthers = [&addOthers_, &reverseAddOthers_]() {
if constexpr (!is_clockwise<RawShape>())
addOthers_();
else
reverseAddOthers_();
auto addOthers = [&rsh, finish, start, &item]() {
if constexpr (!is_clockwise<RawShape>()) {
for(size_t i = start+1; i < finish; i++)
sl::addVertex(rsh, item.vertex(i));
} else {
for(auto i = finish-1; i > start; i--)
sl::addVertex(rsh, item.vertex(static_cast<unsigned long>(i)));
}
};

// Final polygon construction...
Expand Down
4 changes: 2 additions & 2 deletions src/libnest2d/include/libnest2d/selections/firstfit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ class _FirstFitSelection: public SelectionBoilerplate<RawShape> {
}
});

std::for_each(pconfig.m_excluded_regions.begin(), pconfig.m_excluded_regions.end(), [this, &pconfig](Item& itm) {
std::for_each(pconfig.m_excluded_regions.begin(), pconfig.m_excluded_regions.end(), [&pconfig](Item& itm) {
pconfig.m_excluded_items.emplace_back(itm);
});

#ifdef SVGTOOLS_HPP
svg::SVGWriter<RawShape> svgwriter;
std::for_each(first, last, [this,&svgwriter](Item &itm) { svgwriter.writeShape(itm, "none", "blue"); });
std::for_each(first, last, [&svgwriter](Item &itm) { svgwriter.writeShape(itm, "none", "blue"); });
svgwriter.save(boost::filesystem::path("SVG") / "all_items.svg");
#endif

Expand Down
22 changes: 11 additions & 11 deletions src/libnest2d/include/libnest2d/utils/metaloop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ template<int N, class Fn> class MapFn {
// with C++14 because the second parameter's type will depend on the
// type of the parameter pack element that is processed. In C++14 we can
// specify this second parameter type as auto in the lambda parameter list.
inline MapFn(Fn&& fn): fn_(forward<Fn>(fn)) {}
inline MapFn(Fn&& fn): fn_(std::forward<Fn>(fn)) {}

template<class T> void operator ()(T&& pack_element) {
// We provide the index as the first parameter and the pack (or tuple)
// element as the second parameter to the functor.
fn_(N, forward<T>(pack_element));
fn_(N, std::forward<T>(pack_element));
}
};

Expand All @@ -118,7 +118,7 @@ class _MetaLoop<Int<0>, Args...> {

template<class Tup, class Fn>
void run( Tup&& valtup, Fn&& fn) {
MapFn<ARGNUM-N, Fn> {forward<Fn>(fn)} (get<ARGNUM-N>(valtup));
MapFn<ARGNUM-N, Fn> {std::forward<Fn>(fn)} (get<ARGNUM-N>(valtup));
}
};

Expand All @@ -131,11 +131,11 @@ class _MetaLoop<Int<N>, Args...> {

template<class Tup, class Fn>
void run(Tup&& valtup, Fn&& fn) {
MapFn<ARGNUM-N, Fn> {forward<Fn>(fn)} (std::get<ARGNUM-N>(valtup));
MapFn<ARGNUM-N, Fn> {std::forward<Fn>(fn)} (std::get<ARGNUM-N>(valtup));

// Recursive call to process the next element of Args
_MetaLoop<Int<N-1>, Args...> ().run(forward<Tup>(valtup),
forward<Fn>(fn));
_MetaLoop<Int<N-1>, Args...> ().run(std::forward<Tup>(valtup),
std::forward<Fn>(fn));
}
};

Expand Down Expand Up @@ -187,26 +187,26 @@ using MetaLoop = _MetaLoop<Int<sizeof...(Args)-1>, Args...>;
*/
template<class...Args, class Fn>
inline static void apply(Fn&& fn, Args&&...args) {
MetaLoop<Args...>().run(tuple<Args&&...>(forward<Args>(args)...),
forward<Fn>(fn));
MetaLoop<Args...>().run(tuple<Args&&...>(std::forward<Args>(args)...),
std::forward<Fn>(fn));
}

/// The version of apply with a tuple rvalue reference.
template<class...Args, class Fn>
inline static void apply(Fn&& fn, tuple<Args...>&& tup) {
MetaLoop<Args...>().run(std::move(tup), forward<Fn>(fn));
MetaLoop<Args...>().run(std::move(tup), std::forward<Fn>(fn));
}

/// The version of apply with a tuple lvalue reference.
template<class...Args, class Fn>
inline static void apply(Fn&& fn, tuple<Args...>& tup) {
MetaLoop<Args...>().run(tup, forward<Fn>(fn));
MetaLoop<Args...>().run(tup, std::forward<Fn>(fn));
}

/// The version of apply with a tuple const reference.
template<class...Args, class Fn>
inline static void apply(Fn&& fn, const tuple<Args...>& tup) {
MetaLoop<Args...>().run(tup, forward<Fn>(fn));
MetaLoop<Args...>().run(tup, std::forward<Fn>(fn));
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/libslic3r/ArcFitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,24 @@ void ArcFitter::do_arc_fitting(const Points& points, std::vector<PathFittingData
//BBS: can be fit as arc, then save arc data temperarily
last_arc = target_arc;
if (back_index == points.size() - 1) {
result.emplace_back(std::move(PathFittingData{ front_index,
result.emplace_back(PathFittingData{ front_index,
back_index,
last_arc.direction == ArcDirection::Arc_Dir_CCW ? EMovePathType::Arc_move_ccw : EMovePathType::Arc_move_cw,
last_arc }));
last_arc });
front_index = back_index;
}
} else {
if (back_index - front_index > 2) {
//BBS: althought current point_stack can't be fit as arc,
//but previous must can be fit if removing the top in stack, so save last arc
result.emplace_back(std::move(PathFittingData{ front_index,
result.emplace_back(PathFittingData{ front_index,
back_index - 1,
last_arc.direction == ArcDirection::Arc_Dir_CCW ? EMovePathType::Arc_move_ccw : EMovePathType::Arc_move_cw,
last_arc }));
last_arc });
} else {
//BBS: save the first segment as line move when 3 point-line can't be fit as arc move
if (result.empty() || result.back().path_type != EMovePathType::Linear_move)
result.emplace_back(std::move(PathFittingData{front_index, front_index + 1, EMovePathType::Linear_move, ArcSegment()}));
result.emplace_back(PathFittingData{front_index, front_index + 1, EMovePathType::Linear_move, ArcSegment()});
else if(result.back().path_type == EMovePathType::Linear_move)
result.back().end_point_index = front_index + 1;
}
Expand All @@ -87,7 +87,7 @@ void ArcFitter::do_arc_fitting(const Points& points, std::vector<PathFittingData
//BBS: handle the remain data
if (front_index != back_index) {
if (result.empty() || result.back().path_type != EMovePathType::Linear_move)
result.emplace_back(std::move(PathFittingData{front_index, back_index, EMovePathType::Linear_move, ArcSegment()}));
result.emplace_back(PathFittingData{front_index, back_index, EMovePathType::Linear_move, ArcSegment()});
else if (result.back().path_type == EMovePathType::Linear_move)
result.back().end_point_index = back_index;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Arrange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ class AutoArranger {
}
});

m_pck.unfitIndicator([this](std::string name) {
m_pck.unfitIndicator([](std::string name) {
BOOST_LOG_TRIVIAL(debug) << "arrange progress: " + name;
});

Expand Down
7 changes: 4 additions & 3 deletions src/libslic3r/Brim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,14 +590,15 @@ double getadhesionCoeff(const PrintObject* printObject)
for (const ModelVolume* modelVolume : objectVolumes) {
for (auto iter = extrudersFirstLayer.begin(); iter != extrudersFirstLayer.end(); iter++)
if (modelVolume->extruder_id() == *iter) {
if (Model::extruderParamsMap.find(modelVolume->extruder_id()) != Model::extruderParamsMap.end())
if (Model::extruderParamsMap.find(modelVolume->extruder_id()) != Model::extruderParamsMap.end()) {
if (Model::extruderParamsMap.at(modelVolume->extruder_id()).materialName == "PETG" ||
Model::extruderParamsMap.at(modelVolume->extruder_id()).materialName == "PCTG") {
adhesionCoeff = 2;
} else if (Model::extruderParamsMap.at(modelVolume->extruder_id()).materialName == "TPU" ||
Model::extruderParamsMap.at(modelVolume->extruder_id()).materialName == "TPU-AMS") {
adhesionCoeff = 0.5;
}
}
}
}

Expand Down Expand Up @@ -1656,7 +1657,7 @@ ExtrusionEntityCollection makeBrimInfill(const ExPolygons& singleBrimArea, const
Polylines loops_pl = to_polylines(loops);
loops_pl_by_levels.assign(loops_pl.size(), Polylines());
tbb::parallel_for(tbb::blocked_range<size_t>(0, loops_pl.size()),
[&loops_pl_by_levels, &loops_pl, &islands_area](const tbb::blocked_range<size_t>& range) {
[&loops_pl_by_levels, &loops_pl](const tbb::blocked_range<size_t>& range) {
for (size_t i = range.begin(); i < range.end(); ++i) {
loops_pl_by_levels[i] = chain_polylines({ std::move(loops_pl[i]) });
//loops_pl_by_levels[i] = chain_polylines(intersection_pl({ std::move(loops_pl[i]) }, islands_area));
Expand Down Expand Up @@ -1821,7 +1822,7 @@ ExtrusionEntityCollection make_brim(const Print &print, PrintTryCancel try_cance
}
#endif // BRIM_DEBUG_TO_SVG

const bool could_brim_intersects_skirt = std::any_of(print.objects().begin(), print.objects().end(), [&print, &brim_width_map, brim_width_max](PrintObject *object) {
const bool could_brim_intersects_skirt = std::any_of(print.objects().begin(), print.objects().end(), [&print, &brim_width_map](PrintObject *object) {
const BrimType &bt = object->config().brim_type;
return (bt == btOuterOnly || bt == btOuterAndInner || bt == btAutoBrim) && print.config().skirt_distance.value < brim_width_map[object->id()];
});
Expand Down
24 changes: 12 additions & 12 deletions src/libslic3r/Clipper2Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Slic3r::Polylines Paths64_to_polylines(const Clipper2Lib::Paths64& in)
Slic3r::Points points;
points.reserve(path64.size());
for (const Clipper2Lib::Point64& point64 : path64)
points.emplace_back(std::move(Slic3r::Point(point64.x, point64.y)));
out.emplace_back(std::move(Slic3r::Polyline(points)));
}
points.emplace_back(Slic3r::Point(point64.x, point64.y));
out.emplace_back(Slic3r::Polyline(points));
}
return out;
}

Expand All @@ -29,8 +29,8 @@ Clipper2Lib::Paths64 Slic3rPoints_to_Paths64(const std::vector<T>& in)
Clipper2Lib::Path64 path;
path.reserve(item.size());
for (const Slic3r::Point& point : item.points)
path.emplace_back(std::move(Clipper2Lib::Point64(point.x(), point.y())));
out.emplace_back(std::move(path));
path.emplace_back(Clipper2Lib::Point64(point.x(), point.y()));
out.emplace_back(path);
}
return out;
}
Expand All @@ -39,7 +39,7 @@ Points Path64ToPoints(const Clipper2Lib::Path64& path64)
{
Points points;
points.reserve(path64.size());
for (const Clipper2Lib::Point64 &point64 : path64) points.emplace_back(std::move(Slic3r::Point(point64.x, point64.y)));
for (const Clipper2Lib::Point64 &point64 : path64) points.emplace_back(Slic3r::Point(point64.x, point64.y));
return points;
}

Expand Down Expand Up @@ -94,8 +94,8 @@ Clipper2Lib::Paths64 Slic3rPolygons_to_Paths64(const Polygons &in)
for (const Polygon &poly : in) {
Clipper2Lib::Path64 path;
path.reserve(poly.points.size());
for (const Slic3r::Point &point : poly.points) path.emplace_back(std::move(Clipper2Lib::Point64(point.x(), point.y())));
out.emplace_back(std::move(path));
for (const Slic3r::Point &point : poly.points) path.emplace_back(Clipper2Lib::Point64(point.x(), point.y()));
out.emplace_back(path);
}
return out;
}
Expand All @@ -109,8 +109,8 @@ Clipper2Lib::Paths64 Slic3rExPolygons_to_Paths64(const ExPolygons& in)
const auto &poly = expolygon.contour_or_hole(i);
Clipper2Lib::Path64 path;
path.reserve(poly.points.size());
for (const Slic3r::Point &point : poly.points) path.emplace_back(std::move(Clipper2Lib::Point64(point.x(), point.y())));
out.emplace_back(std::move(path));
for (const Slic3r::Point &point : poly.points) path.emplace_back(Clipper2Lib::Point64(point.x(), point.y()));
out.emplace_back(path);
}
}
return out;
Expand All @@ -129,8 +129,8 @@ Polylines _clipper2_pl_open(Clipper2Lib::ClipType clipType, const Slic3r::Polyli

Slic3r::Polylines out;
out.reserve(solution.size() + solution_open.size());
polylines_append(out, std::move(Paths64_to_polylines(solution)));
polylines_append(out, std::move(Paths64_to_polylines(solution_open)));
polylines_append(out, Paths64_to_polylines(solution));
polylines_append(out, Paths64_to_polylines(solution_open));

return out;
}
Expand Down
Loading
Loading