-
-
Notifications
You must be signed in to change notification settings - Fork 882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cura 10728 skirt height for skirt outline #1904
Cura 10728 skirt height for skirt outline #1904
Conversation
This will fix an incorrect format causing test failure on 32-bit architectures.
If user tries to give skirt height more than the model_height. CURA-10728
src/SkirtBrim.cpp
Outdated
skirt_height = std::min(std::max(skirt_height, extruder.settings.get<int>("skirt_height")), static_cast<int>(storage.print_layer_count)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a slight preference for something like this:
skirt_height = std::min(std::max(skirt_height, extruder.settings.get<int>("skirt_height")), static_cast<int>(storage.print_layer_count)); | |
} | |
skirt_height = std::max(skirt_height, extruder.settings.get<int>("skirt_height")); | |
} | |
skirt_height = std::min(skirt_height, static_cast<int>(storage.print_layer_count)); |
It is more readable in my opinion as you sequence the operations more. First you calculate the max skirt height of the various extrudes, then you cap this height to the layer count.
src/SkirtBrim.cpp
Outdated
( | ||
storage.getLayerOutlines(i_layer, include_support, include_prime_tower, external_only, extruder_nr) | ||
); | ||
skirt_height = std::min(std::max(skirt_height, extruder.settings.get<int>("skirt_height")), static_cast<int>(storage.print_layer_count)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the documentation:
* \param extruder_nr The extruder for which to get the outlines. -1 to include outliens for all extruders
We should thus only include the skirt height of all extruders when this variable is set to -1
. Taking some inspiration from this function
CuraEngine/src/sliceDataStorage.cpp
Line 285 in 14bb2f2
if (include_support && (extruder_nr == -1 || extruder_nr == int(mesh_group_settings.get<ExtruderTrain&>("adhesion_extruder_nr").extruder_nr))) |
I would suggest to add something like
skirt_height = std::min(std::max(skirt_height, extruder.settings.get<int>("skirt_height")), static_cast<int>(storage.print_layer_count)); | |
if (extruder_nr == -1 || extruder_nr == extruder.extruder_nr) | |
{ | |
skirt_height = std::min(std::max(skirt_height, extruder.settings.get<int>("skirt_height")), static_cast<int>(storage.print_layer_count)); | |
} |
src/SkirtBrim.cpp
Outdated
for (int i_layer = layer_nr; i_layer < skirt_height; ++i_layer) | ||
{ | ||
for (const auto& extruder : Application::getInstance().current_slice->scene.extruders) | ||
{ | ||
first_layer_outline = | ||
first_layer_outline.unionPolygons | ||
( | ||
storage.getLayerOutlines(i_layer, include_support, include_prime_tower, external_only, extruder.extruder_nr) | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is needed; we have an extruder_nr
parameter, the documentation for this parameter reads
* \param extruder_nr The extruder for which to get the outlines. -1 to include outliens for all extruders
So we should only include the layer_outline for all extruders if extruder_nr
is set to -1
. When executing storage.getLayerOutlines
with this -1
argument should already return the outline of all extruders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy
found issue(s) with the introduced code (1/10)
const utils::integral auto max_resolution, | ||
const utils::floating_point auto AB_magnitude, | ||
const utils::floating_point auto BC_magnitude, | ||
const utils::floating_point auto CD_magnitude) const noexcept | ||
{ | ||
if (BC_magnitude > max_resolution / 10) // TODO: make dedicated front-end setting for this | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for class smooth_fn
{ | |
inline constexpr SmoothFn smooth{}; |
@@ -124,15 +125,24 @@ struct smooth_fn | |||
} | |||
|
|||
template<class Vector> | |||
requires utils::point2d<Vector> || utils::junction<Vector> constexpr auto dotProduct(Vector* point_0, Vector* point_1) const noexcept | |||
requires utils::point2d<Vector> || utils::junction<Vector> | |||
constexpr auto dotProduct(Vector* point_0, Vector* point_1) const noexcept | |||
{ | |||
return std::get<"X">(*point_0) * std::get<"X">(*point_1) + std::get<"Y">(*point_0) * std::get<"Y">(*point_1); | |||
} | |||
|
|||
template<class Point> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter A
template<class Point> | |
constexpr auto isWithinAllowedDeviations(Point* a, Point* B, Point* C, Point* D, const utils::floating_point auto fluid_angle, const utils::integral auto max_resolution, |
Point* B, | ||
Point* C, | ||
Point* D, | ||
const utils::floating_point auto fluid_angle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter A
const utils::floating_point auto fluid_angle, | |
const double cos_A = std::acos(cosAngle(a, B, C, AB_magnitude, BC_magnitude)); |
Point* C, | ||
Point* D, | ||
const utils::floating_point auto fluid_angle, | ||
const utils::integral auto max_resolution, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter A
const utils::integral auto max_resolution, | |
const double cos_B = std::acos(cosAngle(a, B, D, AB_magnitude, CD_magnitude)); |
@@ -124,15 +125,24 @@ struct smooth_fn | |||
} | |||
|
|||
template<class Vector> | |||
requires utils::point2d<Vector> || utils::junction<Vector> constexpr auto dotProduct(Vector* point_0, Vector* point_1) const noexcept | |||
requires utils::point2d<Vector> || utils::junction<Vector> | |||
constexpr auto dotProduct(Vector* point_0, Vector* point_1) const noexcept | |||
{ | |||
return std::get<"X">(*point_0) * std::get<"X">(*point_1) + std::get<"Y">(*point_0) * std::get<"Y">(*point_1); | |||
} | |||
|
|||
template<class Point> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter B
template<class Point> | |
constexpr auto isWithinAllowedDeviations(Point* A, Point* b, Point* C, Point* D, const utils::floating_point auto fluid_angle, const utils::integral auto max_resolution, |
Point* B, | ||
Point* C, | ||
Point* D, | ||
const utils::floating_point auto fluid_angle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter B
const utils::floating_point auto fluid_angle, | |
const double cos_A = std::acos(cosAngle(A, b, C, AB_magnitude, BC_magnitude)); |
Point* C, | ||
Point* D, | ||
const utils::floating_point auto fluid_angle, | ||
const utils::integral auto max_resolution, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter B
const utils::integral auto max_resolution, | |
const double cos_B = std::acos(cosAngle(A, b, D, AB_magnitude, CD_magnitude)); |
@@ -124,15 +125,24 @@ struct smooth_fn | |||
} | |||
|
|||
template<class Vector> | |||
requires utils::point2d<Vector> || utils::junction<Vector> constexpr auto dotProduct(Vector* point_0, Vector* point_1) const noexcept | |||
requires utils::point2d<Vector> || utils::junction<Vector> | |||
constexpr auto dotProduct(Vector* point_0, Vector* point_1) const noexcept | |||
{ | |||
return std::get<"X">(*point_0) * std::get<"X">(*point_1) + std::get<"Y">(*point_0) * std::get<"Y">(*point_1); | |||
} | |||
|
|||
template<class Point> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter C
template<class Point> | |
constexpr auto isWithinAllowedDeviations(Point* A, Point* B, Point* c, Point* D, const utils::floating_point auto fluid_angle, const utils::integral auto max_resolution, |
Point* B, | ||
Point* C, | ||
Point* D, | ||
const utils::floating_point auto fluid_angle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter C
const utils::floating_point auto fluid_angle, | |
const double cos_A = std::acos(cosAngle(A, B, c, AB_magnitude, BC_magnitude)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy
found issue(s) with the introduced code (2/10)
@@ -124,15 +125,24 @@ struct smooth_fn | |||
} | |||
|
|||
template<class Vector> | |||
requires utils::point2d<Vector> || utils::junction<Vector> constexpr auto dotProduct(Vector* point_0, Vector* point_1) const noexcept | |||
requires utils::point2d<Vector> || utils::junction<Vector> | |||
constexpr auto dotProduct(Vector* point_0, Vector* point_1) const noexcept | |||
{ | |||
return std::get<"X">(*point_0) * std::get<"X">(*point_1) + std::get<"Y">(*point_0) * std::get<"Y">(*point_1); | |||
} | |||
|
|||
template<class Point> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter D
template<class Point> | |
constexpr auto isWithinAllowedDeviations(Point* A, Point* B, Point* C, Point* d, const utils::floating_point auto fluid_angle, const utils::integral auto max_resolution, |
Point* C, | ||
Point* D, | ||
const utils::floating_point auto fluid_angle, | ||
const utils::integral auto max_resolution, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter D
const utils::integral auto max_resolution, | |
const double cos_B = std::acos(cosAngle(A, B, d, AB_magnitude, CD_magnitude)); |
@@ -124,15 +125,24 @@ struct smooth_fn | |||
} | |||
|
|||
template<class Vector> | |||
requires utils::point2d<Vector> || utils::junction<Vector> constexpr auto dotProduct(Vector* point_0, Vector* point_1) const noexcept | |||
requires utils::point2d<Vector> || utils::junction<Vector> | |||
constexpr auto dotProduct(Vector* point_0, Vector* point_1) const noexcept | |||
{ | |||
return std::get<"X">(*point_0) * std::get<"X">(*point_1) + std::get<"Y">(*point_0) * std::get<"Y">(*point_1); | |||
} | |||
|
|||
template<class Point> | |||
requires utils::point2d<Point> || utils::junction<Point> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter AB_magnitude
requires utils::point2d<Point> || utils::junction<Point> | |
const utils::floating_point auto ab_magnitude, const utils::floating_point auto BC_magnitude, const utils::floating_point auto CD_magnitude) const noexcept |
Point* B, | ||
Point* C, | ||
Point* D, | ||
const utils::floating_point auto fluid_angle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter AB_magnitude
const utils::floating_point auto fluid_angle, | |
const double cos_A = std::acos(cosAngle(A, B, C, ab_magnitude, BC_magnitude)); |
Point* C, | ||
Point* D, | ||
const utils::floating_point auto fluid_angle, | ||
const utils::integral auto max_resolution, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter AB_magnitude
const utils::integral auto max_resolution, | |
const double cos_B = std::acos(cosAngle(A, B, D, ab_magnitude, CD_magnitude)); |
@@ -124,15 +125,24 @@ struct smooth_fn | |||
} | |||
|
|||
template<class Vector> | |||
requires utils::point2d<Vector> || utils::junction<Vector> constexpr auto dotProduct(Vector* point_0, Vector* point_1) const noexcept | |||
requires utils::point2d<Vector> || utils::junction<Vector> | |||
constexpr auto dotProduct(Vector* point_0, Vector* point_1) const noexcept | |||
{ | |||
return std::get<"X">(*point_0) * std::get<"X">(*point_1) + std::get<"Y">(*point_0) * std::get<"Y">(*point_1); | |||
} | |||
|
|||
template<class Point> | |||
requires utils::point2d<Point> || utils::junction<Point> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter BC_magnitude
requires utils::point2d<Point> || utils::junction<Point> | |
const utils::floating_point auto AB_magnitude, const utils::floating_point auto bc_magnitude, const utils::floating_point auto CD_magnitude) const noexcept |
constexpr auto isWithinAllowedDeviations(Point* A, Point* B, Point* C, Point* D, const utils::floating_point auto fluid_angle, const utils::integral auto max_resolution, | ||
const utils::floating_point auto AB_magnitude, const utils::floating_point auto BC_magnitude, const utils::floating_point auto CD_magnitude) const noexcept | ||
constexpr auto isWithinAllowedDeviations( | ||
Point* A, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter BC_magnitude
Point* A, | |
if (bc_magnitude > max_resolution / 10) // TODO: make dedicated front-end setting for this |
Point* B, | ||
Point* C, | ||
Point* D, | ||
const utils::floating_point auto fluid_angle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter BC_magnitude
const utils::floating_point auto fluid_angle, | |
const double cos_A = std::acos(cosAngle(A, B, C, AB_magnitude, bc_magnitude)); |
@@ -124,15 +125,24 @@ struct smooth_fn | |||
} | |||
|
|||
template<class Vector> | |||
requires utils::point2d<Vector> || utils::junction<Vector> constexpr auto dotProduct(Vector* point_0, Vector* point_1) const noexcept | |||
requires utils::point2d<Vector> || utils::junction<Vector> | |||
constexpr auto dotProduct(Vector* point_0, Vector* point_1) const noexcept | |||
{ | |||
return std::get<"X">(*point_0) * std::get<"X">(*point_1) + std::get<"Y">(*point_0) * std::get<"Y">(*point_1); | |||
} | |||
|
|||
template<class Point> | |||
requires utils::point2d<Point> || utils::junction<Point> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter CD_magnitude
requires utils::point2d<Point> || utils::junction<Point> | |
const utils::floating_point auto AB_magnitude, const utils::floating_point auto BC_magnitude, const utils::floating_point auto cd_magnitude) const noexcept |
Point* C, | ||
Point* D, | ||
const utils::floating_point auto fluid_angle, | ||
const utils::integral auto max_resolution, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter CD_magnitude
const utils::integral auto max_resolution, | |
const double cos_B = std::acos(cosAngle(A, B, D, AB_magnitude, cd_magnitude)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy
found issue(s) with the introduced code (3/10)
constexpr auto isWithinAllowedDeviations(Point* A, Point* B, Point* C, Point* D, const utils::floating_point auto fluid_angle, const utils::integral auto max_resolution, | ||
const utils::floating_point auto AB_magnitude, const utils::floating_point auto BC_magnitude, const utils::floating_point auto CD_magnitude) const noexcept | ||
constexpr auto isWithinAllowedDeviations( | ||
Point* A, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10 is a magic number; consider replacing it with a named constant
Point* B, | ||
Point* C, | ||
Point* D, | ||
const utils::floating_point auto fluid_angle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for variable cos_A
const utils::floating_point auto fluid_angle, | |
const double cos_a = std::acos(cosAngle(A, B, C, AB_magnitude, BC_magnitude)); |
Point* D, | ||
const utils::floating_point auto fluid_angle, | ||
const utils::integral auto max_resolution, | ||
const utils::floating_point auto AB_magnitude, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for variable cos_A
const utils::floating_point auto AB_magnitude, | |
const auto abs_angle = std::abs(cos_a - cos_B); |
Point* B, | ||
Point* C, | ||
Point* D, | ||
const utils::floating_point auto fluid_angle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no member named acos
in namespace std
Point* C, | ||
Point* D, | ||
const utils::floating_point auto fluid_angle, | ||
const utils::integral auto max_resolution, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for variable cos_B
const utils::integral auto max_resolution, | |
const double cos_b = std::acos(cosAngle(A, B, D, AB_magnitude, CD_magnitude)); |
Point* D, | ||
const utils::floating_point auto fluid_angle, | ||
const utils::integral auto max_resolution, | ||
const utils::floating_point auto AB_magnitude, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for variable cos_B
const utils::floating_point auto AB_magnitude, | |
const auto abs_angle = std::abs(cos_A - cos_b); |
Point* C, | ||
Point* D, | ||
const utils::floating_point auto fluid_angle, | ||
const utils::integral auto max_resolution, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no member named acos
in namespace std
src/SkirtBrim.cpp
Outdated
#include "SkirtBrim.h" | ||
|
||
#include "Application.h" | ||
#include "ExtruderTrain.h" | ||
#include "Slice.h" | ||
#include "settings/EnumSettings.h" | ||
#include "settings/types/Ratio.h" | ||
#include "sliceDataStorage.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#includes are not sorted properly
#include "sliceDataStorage.h" | |
#include "settings/EnumSettings.h" |
src/SkirtBrim.cpp
Outdated
#include "SkirtBrim.h" | ||
|
||
#include "Application.h" | ||
#include "ExtruderTrain.h" | ||
#include "Slice.h" | ||
#include "settings/EnumSettings.h" | ||
#include "settings/types/Ratio.h" | ||
#include "sliceDataStorage.h" | ||
#include "support.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#includes are not sorted properly
#include "support.h" | |
#include "settings/types/Ratio.h" |
src/SkirtBrim.cpp
Outdated
#include "settings/types/Ratio.h" | ||
#include "sliceDataStorage.h" | ||
#include "support.h" | ||
#include "utils/Simplify.h" //Simplifying the brim/skirt at every inset. | ||
#include "settings/EnumSettings.h" | ||
#include "utils/PolylineStitcher.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#includes are not sorted properly
#include "utils/PolylineStitcher.h" | |
#include "sliceDataStorage.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy
found issue(s) with the introduced code (4/10)
src/SkirtBrim.cpp
Outdated
#include "utils/PolylineStitcher.h" | ||
#include "utils/Simplify.h" //Simplifying the brim/skirt at every inset. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#includes are not sorted properly
#include "utils/Simplify.h" //Simplifying the brim/skirt at every inset. | |
#include "support.h" |
src/SkirtBrim.cpp
Outdated
#include "utils/PolylineStitcher.h" | ||
#include "utils/Simplify.h" //Simplifying the brim/skirt at every inset. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#includes are not sorted properly
#include "utils/PolylineStitcher.h" |
src/SkirtBrim.cpp
Outdated
#include "utils/PolylineStitcher.h" | ||
#include "utils/Simplify.h" //Simplifying the brim/skirt at every inset. | ||
|
||
#include <spdlog/spdlog.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#includes are not sorted properly
#include <spdlog/spdlog.h> | |
#include "utils/Simplify.h" //Simplifying the brim/skirt at every inset. |
src/SkirtBrim.cpp
Outdated
SkirtBrim::SkirtBrim(SliceDataStorage& storage) | ||
: storage(storage) | ||
, adhesion_type(Application::getInstance().current_slice->scene.current_mesh_group->settings.get<EPlatformAdhesion>("adhesion_type")) | ||
, has_ooze_shield(storage.oozeShield.size() > 0 && storage.oozeShield[0].size() > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the empty
method should be used to check for emptiness instead of size
, has_ooze_shield(storage.oozeShield.size() > 0 && storage.oozeShield[0].size() > 0) | |
has_ooze_shield(!storage.oozeShield.empty() && storage.oozeShield[0].size() > 0), |
src/SkirtBrim.cpp
Outdated
SkirtBrim::SkirtBrim(SliceDataStorage& storage) | ||
: storage(storage) | ||
, adhesion_type(Application::getInstance().current_slice->scene.current_mesh_group->settings.get<EPlatformAdhesion>("adhesion_type")) | ||
, has_ooze_shield(storage.oozeShield.size() > 0 && storage.oozeShield[0].size() > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the empty
method should be used to check for emptiness instead of size
, has_ooze_shield(storage.oozeShield.size() > 0 && storage.oozeShield[0].size() > 0) | |
has_ooze_shield(storage.oozeShield.size() > 0 && !storage.oozeShield[0].empty()), |
src/SkirtBrim.cpp
Outdated
: storage(storage) | ||
, adhesion_type(Application::getInstance().current_slice->scene.current_mesh_group->settings.get<EPlatformAdhesion>("adhesion_type")) | ||
, has_ooze_shield(storage.oozeShield.size() > 0 && storage.oozeShield[0].size() > 0) | ||
, has_draft_shield(storage.draft_protection_shield.size() > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the empty
method should be used to check for emptiness instead of size
, has_draft_shield(storage.draft_protection_shield.size() > 0) | |
has_draft_shield(!storage.draft_protection_shield.empty()), |
src/SkirtBrim.cpp
Outdated
, has_ooze_shield(storage.oozeShield.size() > 0 && storage.oozeShield[0].size() > 0) | ||
, has_draft_shield(storage.draft_protection_shield.size() > 0) | ||
, extruders(Application::getInstance().current_slice->scene.extruders) | ||
, extruder_count(extruders.size()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
narrowing conversion from std::vector::size_type
(aka unsigned long
) to signed type int
is implementation-defined
src/SkirtBrim.cpp
Outdated
, has_draft_shield(storage.draft_protection_shield.size() > 0) | ||
, extruders(Application::getInstance().current_slice->scene.extruders) | ||
, extruder_count(extruders.size()) | ||
, extruder_is_used(storage.getExtrudersUsed()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first_used_extruder_nr
should be initialized in a member initializer of the constructor
, extruder_is_used(storage.getExtrudersUsed()) | |
extruder_is_used(storage.getExtrudersUsed()), first_used_extruder_nr(0) |
src/SkirtBrim.cpp
Outdated
, has_draft_shield(storage.draft_protection_shield.size() > 0) | ||
, extruders(Application::getInstance().current_slice->scene.extruders) | ||
, extruder_count(extruders.size()) | ||
, extruder_is_used(storage.getExtrudersUsed()) | ||
{ | ||
first_used_extruder_nr = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first_used_extruder_nr
should be initialized in a member initializer of the constructor
first_used_extruder_nr = 0; | |
src/SkirtBrim.cpp
Outdated
@@ -192,7 +192,7 @@ void SkirtBrim::generate() | |||
|
|||
// Secondary brim of all other materials which don;t meet minimum length constriant yet | |||
generateSecondarySkirtBrim(covered_area, allowed_areas_per_extruder, total_length); | |||
|
|||
// simplify paths to prevent buffer unnerruns in firmware | |||
const Settings& global_settings = Application::getInstance().current_slice->scene.current_mesh_group->settings; | |||
const coord_t maximum_resolution = global_settings.get<coord_t>("meshfix_maximum_resolution"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use auto when initializing with a template cast to avoid duplicating the type name
const coord_t maximum_resolution = global_settings.get<coord_t>("meshfix_maximum_resolution"); | |
const auto maximum_resolution = global_settings.get<coord_t>("meshfix_maximum_resolution"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy
found issue(s) with the introduced code (5/10)
total_length[offset.extruder_nr] < skirt_brim_minimal_length[offset.extruder_nr] && // This was the last offset of this extruder, but the brim lines don't meet minimal length yet | ||
|
||
if (offset.is_last && total_length[offset.extruder_nr] < skirt_brim_minimal_length[offset.extruder_nr] | ||
&& // This was the last offset of this extruder, but the brim lines don't meet minimal length yet | ||
total_length[offset.extruder_nr] > 0u // No lines got added; we have no extrusion lines to build on | ||
) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
integer literal has suffix u
, which is not uppercase
{ | |
total_length[offset.extruder_nr] > 0U // No lines got added; we have no extrusion lines to build on |
src/SkirtBrim.cpp
Outdated
@@ -267,7 +263,7 @@ Polygons SkirtBrim::getInternalHoleExclusionArea(const Polygons& outline, const | |||
{ | |||
Polygon hole_poly = part[hole_idx]; | |||
hole_poly.reverse(); | |||
Polygons disallowed_region = hole_poly.offset(10u).difference(hole_poly.offset( - line_widths[extruder_nr] / 2 - hole_brim_distance)); | |||
Polygons disallowed_region = hole_poly.offset(10u).difference(hole_poly.offset(-line_widths[extruder_nr] / 2 - hole_brim_distance)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backward branch (for loop) is ID-dependent due to variable reference to part
and may cause performance degradation
src/SkirtBrim.cpp
Outdated
local_brim.add(closed_polygons_brim); | ||
|
||
auto open_polylines_brim = storage.skirt_brim[offset.extruder_nr][reference_idx].open_polylines | ||
.offsetPolyLine(offset_dist, ClipperLib::jtRound); | ||
auto open_polylines_brim = storage.skirt_brim[offset.extruder_nr][reference_idx].open_polylines.offsetPolyLine(offset_dist, ClipperLib::jtRound); | ||
local_brim.add(open_polylines_brim); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not use array subscript when the index is not an integer constant expression
src/SkirtBrim.cpp
Outdated
local_brim.add(closed_polygons_brim); | ||
|
||
auto open_polylines_brim = storage.skirt_brim[offset.extruder_nr][reference_idx].open_polylines | ||
.offsetPolyLine(offset_dist, ClipperLib::jtRound); | ||
auto open_polylines_brim = storage.skirt_brim[offset.extruder_nr][reference_idx].open_polylines.offsetPolyLine(offset_dist, ClipperLib::jtRound); | ||
local_brim.add(open_polylines_brim); | ||
local_brim.unionPolygons(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
narrowing conversion from __gnu_cxx::__alloc_traits<std::allocator<long long>, long long>::value_type
(aka long long
) to signed type int
is implementation-defined
src/SkirtBrim.cpp
Outdated
@@ -373,29 +367,39 @@ Polygons SkirtBrim::getFirstLayerOutline(const int extruder_nr /* = -1 */) | |||
Polygons first_layer_outline; | |||
Settings& global_settings = Application::getInstance().current_slice->scene.current_mesh_group->settings; | |||
int reference_extruder_nr = skirt_brim_extruder_nr; | |||
assert( ! (reference_extruder_nr == -1 && extruder_nr == -1) && "We should only request the outlines of all layers when the brim is being generated for only one material"); | |||
assert(! (reference_extruder_nr == -1 && extruder_nr == -1) && "We should only request the outlines of all layers when the brim is being generated for only one material"); | |||
if (reference_extruder_nr == -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function getFirstLayerOutline
has cognitive complexity of 43 (threshold 25)
src/SkirtBrim.cpp
Outdated
@@ -373,29 +367,39 @@ Polygons SkirtBrim::getFirstLayerOutline(const int extruder_nr /* = -1 */) | |||
Polygons first_layer_outline; | |||
Settings& global_settings = Application::getInstance().current_slice->scene.current_mesh_group->settings; | |||
int reference_extruder_nr = skirt_brim_extruder_nr; | |||
assert( ! (reference_extruder_nr == -1 && extruder_nr == -1) && "We should only request the outlines of all layers when the brim is being generated for only one material"); | |||
assert(! (reference_extruder_nr == -1 && extruder_nr == -1) && "We should only request the outlines of all layers when the brim is being generated for only one material"); | |||
if (reference_extruder_nr == -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function getFirstLayerOutline
exceeds recommended size/complexity thresholds
for (const auto& extruder : Application::getInstance().current_slice->scene.extruders) | ||
{ | ||
first_layer_outline | ||
= first_layer_outline.unionPolygons(storage.getLayerOutlines(i_layer, include_support, include_prime_tower, external_only, extruder.extruder_nr)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backward branch (for loop) is ID-dependent due to variable reference to i_layer
and may cause performance degradation
src/SkirtBrim.cpp
Outdated
@@ -543,7 +544,8 @@ void SkirtBrim::generateShieldBrim(Polygons& brim_covered_area, std::vector<Poly | |||
while (shield_brim.size() > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
narrowing conversion from long long
to signed type int
is implementation-defined
src/SkirtBrim.cpp
Outdated
@@ -543,7 +544,8 @@ void SkirtBrim::generateShieldBrim(Polygons& brim_covered_area, std::vector<Poly | |||
while (shield_brim.size() > 0) | |||
{ | |||
shield_brim = shield_brim.offset(-primary_extruder_skirt_brim_line_width); | |||
storage.skirt_brim[extruder_nr].back().closed_polygons.add(shield_brim); // throw all polygons for the shileds onto one heap; because the brim lines are generated from both sides the order will not be important | |||
storage.skirt_brim[extruder_nr].back().closed_polygons.add( | |||
shield_brim); // throw all polygons for the shileds onto one heap; because the brim lines are generated from both sides the order will not be important |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
narrowing conversion from long long
to signed type int
is implementation-defined
src/SkirtBrim.cpp
Outdated
@@ -588,19 +590,19 @@ void SkirtBrim::generateSecondarySkirtBrim(Polygons& covered_area, std::vector<P | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable offset_from_reference
is not initialized
} | |
coord_t offset_from_reference = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy
found issue(s) with the introduced code (6/10)
src/SkirtBrim.cpp
Outdated
storage.skirt_brim[extruder_nr].emplace_back(); | ||
SkirtBrimLine& output_location = storage.skirt_brim[extruder_nr].back(); | ||
coord_t added_length = generateOffset(extra_offset, covered_area, allowed_areas_per_extruder, output_location); | ||
|
||
if ( ! added_length) | ||
if (! added_length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not use array subscript when the index is not an integer constant expression
src/SkirtBrim.cpp
Outdated
storage.skirt_brim[extruder_nr].emplace_back(); | ||
SkirtBrimLine& output_location = storage.skirt_brim[extruder_nr].back(); | ||
coord_t added_length = generateOffset(extra_offset, covered_area, allowed_areas_per_extruder, output_location); | ||
|
||
if ( ! added_length) | ||
if (! added_length) | ||
{ | ||
spdlog::warn("Couldn't satisfy minimum length constraint of extruder {}!\n", extruder_nr); | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not use array subscript when the index is not an integer constant expression
src/SkirtBrim.cpp
Outdated
storage.skirt_brim[extruder_nr].emplace_back(); | ||
SkirtBrimLine& output_location = storage.skirt_brim[extruder_nr].back(); | ||
coord_t added_length = generateOffset(extra_offset, covered_area, allowed_areas_per_extruder, output_location); | ||
|
||
if ( ! added_length) | ||
if (! added_length) | ||
{ | ||
spdlog::warn("Couldn't satisfy minimum length constraint of extruder {}!\n", extruder_nr); | ||
break; | ||
} | ||
|
||
total_length[extra_offset.extruder_nr] += added_length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not use array subscript when the index is not an integer constant expression
src/SkirtBrim.cpp
Outdated
{ | ||
spdlog::warn("Couldn't satisfy minimum length constraint of extruder {}!\n", extruder_nr); | ||
break; | ||
} | ||
|
||
total_length[extra_offset.extruder_nr] += added_length; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not use array subscript when the index is not an integer constant expression
src/SkirtBrim.cpp
Outdated
{ | ||
spdlog::warn("Couldn't satisfy minimum length constraint of extruder {}!\n", extruder_nr); | ||
break; | ||
} | ||
|
||
total_length[extra_offset.extruder_nr] += added_length; | ||
|
||
first = false; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implicit conversion cura::coord_t
(aka long long
) -> bool
} | |
if ( added_length) |
src/SkirtBrim.cpp
Outdated
{ | ||
spdlog::warn("Couldn't satisfy minimum length constraint of extruder {}!\n", extruder_nr); | ||
break; | ||
} | ||
|
||
total_length[extra_offset.extruder_nr] += added_length; | ||
|
||
first = false; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implicit conversion cura::coord_t
(aka long long
) -> bool
} | |
if ( ! added_length == 0) |
#include "utils/linearAlg2D.h" | ||
#include "utils/PolygonsPointIndex.h" | ||
#include "pathPlanning/CombPaths.h" | ||
#include "pathPlanning/LinePolygonsCrossings.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#includes are not sorted properly
#include "pathPlanning/LinePolygonsCrossings.h" | |
#include "Application.h" |
#include "utils/linearAlg2D.h" | ||
#include "utils/PolygonsPointIndex.h" | ||
#include "pathPlanning/CombPaths.h" | ||
#include "pathPlanning/LinePolygonsCrossings.h" | ||
#include "sliceDataStorage.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#includes are not sorted properly
#include "sliceDataStorage.h" | |
#include "ExtruderTrain.h" |
#include "sliceDataStorage.h" | ||
#include "utils/PolygonsPointIndex.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#includes are not sorted properly
#include "utils/PolygonsPointIndex.h" | |
#include "Slice.h" |
#include "sliceDataStorage.h" | ||
#include "utils/PolygonsPointIndex.h" | ||
#include "utils/SVG.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#includes are not sorted properly
#include "utils/SVG.h" | |
#include "pathPlanning/CombPaths.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy
found issue(s) with the introduced code (7/10)
#include "utils/SVG.h" | ||
#include "utils/linearAlg2D.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#includes are not sorted properly
#include "utils/linearAlg2D.h" | |
#include "pathPlanning/LinePolygonsCrossings.h" |
#include "utils/SVG.h" | ||
#include "utils/linearAlg2D.h" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#includes are not sorted properly
#include "sliceDataStorage.h" |
|
||
namespace cura { | ||
#include <algorithm> | ||
#include <functional> // function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#includes are not sorted properly
#include <functional> // function | |
#include "utils/SVG.h" |
namespace cura { | ||
#include <algorithm> | ||
#include <functional> // function | ||
#include <unordered_set> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#includes are not sorted properly
#include <unordered_set> | |
#include "utils/linearAlg2D.h" |
|
||
LocToLineGrid& Comb::getOutsideLocToLine(const ExtruderTrain& train) | ||
{ | ||
if (outside_loc_to_line[train.extruder_nr] == nullptr) | ||
{ | ||
outside_loc_to_line[train.extruder_nr] = | ||
PolygonUtils::createLocToLineGrid(getBoundaryOutside(train), offset_from_inside_to_outside * 3 / 2); | ||
outside_loc_to_line[train.extruder_nr] = PolygonUtils::createLocToLineGrid(getBoundaryOutside(train), offset_from_inside_to_outside * 3 / 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
narrowing conversion from long long
to signed type int
is implementation-defined
@@ -34,8 +34,7 @@ Polygons& Comb::getBoundaryOutside(const ExtruderTrain& train) | |||
if (boundary_outside[train.extruder_nr].empty()) | |||
{ | |||
bool travel_avoid_supports = train.settings.get<bool>("travel_avoid_supports"); | |||
boundary_outside[train.extruder_nr] = | |||
storage.getLayerOutlines(layer_nr, travel_avoid_supports, travel_avoid_supports).offset(travel_avoid_distance); | |||
boundary_outside[train.extruder_nr] = storage.getLayerOutlines(layer_nr, travel_avoid_supports, travel_avoid_supports).offset(travel_avoid_distance); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
narrowing conversion from cura::coord_t
(aka long long
) to signed type int
is implementation-defined
@@ -55,32 +53,39 @@ LocToLineGrid& Comb::getModelBoundaryLocToLine(const ExtruderTrain& train) | |||
{ | |||
if (model_boundary_loc_to_line[train.extruder_nr] == nullptr) | |||
{ | |||
model_boundary_loc_to_line[train.extruder_nr] = | |||
PolygonUtils::createLocToLineGrid(getModelBoundary(train), offset_from_inside_to_outside * 3 / 2); | |||
model_boundary_loc_to_line[train.extruder_nr] = PolygonUtils::createLocToLineGrid(getModelBoundary(train), offset_from_inside_to_outside * 3 / 2); | |||
} | |||
return *model_boundary_loc_to_line[train.extruder_nr]; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
narrowing conversion from long long
to signed type int
is implementation-defined
#include "Application.h" | ||
#include "ExtruderTrain.h" | ||
#include "Slice.h" | ||
#include "utils/linearAlg2D.h" | ||
#include "utils/PolygonsPointIndex.h" | ||
#include "pathPlanning/CombPaths.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass by value and use std::move
#include "pathPlanning/CombPaths.h" | |
#include <utility> | |
Comb::Comb( | ||
const SliceDataStorage& storage, | ||
const LayerIndex layer_nr, | ||
const Polygons& comb_boundary_inside_minimum, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass by value and use std::move
const Polygons& comb_boundary_inside_minimum, | |
Comb::Comb(const SliceDataStorage& storage, const LayerIndex layer_nr, Polygons comb_boundary_inside_minimum, const Polygons& comb_boundary_inside_optimal, coord_t comb_boundary_offset, coord_t travel_avoid_distance, coord_t move_inside_distance) |
coord_t move_inside_distance) | ||
: storage(storage) | ||
, layer_nr(layer_nr) | ||
, offset_from_outlines(comb_boundary_offset) // between second wall and infill / other walls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass by value and use std::move
, offset_from_outlines(comb_boundary_offset) // between second wall and infill / other walls | |
, boundary_inside_minimum(std::move( comb_boundary_inside_minimum ) // copy the boundary, because the partsView_inside will reorder the polygons |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy
found issue(s) with the introduced code (8/10)
coord_t move_inside_distance) | ||
: storage(storage) | ||
, layer_nr(layer_nr) | ||
, offset_from_outlines(comb_boundary_offset) // between second wall and infill / other walls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass by value and use std::move
, offset_from_outlines(comb_boundary_offset) // between second wall and infill / other walls | |
, boundary_inside_minimum( comb_boundary_inside_minimum )) // copy the boundary, because the partsView_inside will reorder the polygons |
Comb::Comb( | ||
const SliceDataStorage& storage, | ||
const LayerIndex layer_nr, | ||
const Polygons& comb_boundary_inside_minimum, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass by value and use std::move
const Polygons& comb_boundary_inside_minimum, | |
Comb::Comb(const SliceDataStorage& storage, const LayerIndex layer_nr, const Polygons& comb_boundary_inside_minimum, Polygons comb_boundary_inside_optimal, coord_t comb_boundary_offset, coord_t travel_avoid_distance, coord_t move_inside_distance) |
: storage(storage) | ||
, layer_nr(layer_nr) | ||
, offset_from_outlines(comb_boundary_offset) // between second wall and infill / other walls | ||
, max_moveInside_distance2(offset_from_outlines * offset_from_outlines) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass by value and use std::move
, max_moveInside_distance2(offset_from_outlines * offset_from_outlines) | |
, boundary_inside_optimal(std::move( comb_boundary_inside_optimal ) // copy the boundary, because the partsView_inside will reorder the polygons |
: storage(storage) | ||
, layer_nr(layer_nr) | ||
, offset_from_outlines(comb_boundary_offset) // between second wall and infill / other walls | ||
, max_moveInside_distance2(offset_from_outlines * offset_from_outlines) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass by value and use std::move
, max_moveInside_distance2(offset_from_outlines * offset_from_outlines) | |
, boundary_inside_optimal( comb_boundary_inside_optimal )) // copy the boundary, because the partsView_inside will reorder the polygons |
, max_moveInside_distance2(offset_from_outlines * offset_from_outlines) | ||
, offset_from_inside_to_outside(offset_from_outlines + travel_avoid_distance) | ||
, max_crossing_dist2( | ||
offset_from_inside_to_outside * offset_from_inside_to_outside |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
narrowing conversion from cura::coord_t
(aka long long
) to signed type int
is implementation-defined
, offset_from_inside_to_outside(offset_from_outlines + travel_avoid_distance) | ||
, max_crossing_dist2( | ||
offset_from_inside_to_outside * offset_from_inside_to_outside | ||
* 2) // so max_crossing_dist = offset_from_inside_to_outside * sqrt(2) =approx 1.5 to allow for slightly diagonal crossings and slightly inaccurate crossing computation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
narrowing conversion from cura::coord_t
(aka long long
) to signed type int
is implementation-defined
, partsView_inside_minimum(boundary_inside_minimum.splitIntoPartsView()) // WARNING !! changes the order of boundary_inside !! | ||
, partsView_inside_optimal(boundary_inside_optimal.splitIntoPartsView()) // WARNING !! changes the order of boundary_inside !! | ||
, inside_loc_to_line_minimum(PolygonUtils::createLocToLineGrid(boundary_inside_minimum, comb_boundary_offset)) | ||
, inside_loc_to_line_optimal(PolygonUtils::createLocToLineGrid(boundary_inside_optimal, comb_boundary_offset)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function calc
has cognitive complexity of 57 (threshold 25)
, partsView_inside_minimum(boundary_inside_minimum.splitIntoPartsView()) // WARNING !! changes the order of boundary_inside !! | ||
, partsView_inside_optimal(boundary_inside_optimal.splitIntoPartsView()) // WARNING !! changes the order of boundary_inside !! | ||
, inside_loc_to_line_minimum(PolygonUtils::createLocToLineGrid(boundary_inside_minimum, comb_boundary_offset)) | ||
, inside_loc_to_line_optimal(PolygonUtils::createLocToLineGrid(boundary_inside_optimal, comb_boundary_offset)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function calc
exceeds recommended size/complexity thresholds
{ | ||
} | ||
|
||
bool Comb::calc | ||
( | ||
bool Comb::calc( | ||
bool perform_z_hops, | ||
bool perform_z_hops_only_when_collides, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter _start_inside
bool perform_z_hops_only_when_collides, | |
bool start_inside, |
{ | ||
if(shorterThen(end_point - start_point, max_comb_distance_ignored)) | ||
if (shorterThen(end_point - start_point, max_comb_distance_ignored)) | ||
{ | ||
return true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter _start_inside
} | |
const bool start_inside = moveInside(boundary_inside_optimal, start_inside, inside_loc_to_line_optimal.get(), start_point, start_inside_poly); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy
found issue(s) with the introduced code (9/10)
*inside_loc_to_line_optimal, | ||
start_point, | ||
end_point, | ||
comb_paths.back(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter _start_inside
comb_paths.back(), | |
const bool start_inside_min = moveInside(boundary_inside_minimum, start_inside, inside_loc_to_line_minimum.get(), start_point, start_inside_poly_min); |
{ | ||
} | ||
|
||
bool Comb::calc | ||
( | ||
bool Comb::calc( | ||
bool perform_z_hops, | ||
bool perform_z_hops_only_when_collides, | ||
const ExtruderTrain& train, // NOTE: USe for travel settings and 'extruder-nr' only, don't use for z-hop/retraction/wipe settings, as that should also be settable per mesh! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter _end_inside
const ExtruderTrain& train, // NOTE: USe for travel settings and 'extruder-nr' only, don't use for z-hop/retraction/wipe settings, as that should also be settable per mesh! | |
bool end_inside, |
{ | ||
return true; | ||
} | ||
const Point travel_end_point_before_combing = end_point; | ||
//Move start and end point inside the optimal comb boundary | ||
// Move start and end point inside the optimal comb boundary | ||
unsigned int start_inside_poly = NO_INDEX; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter _end_inside
unsigned int start_inside_poly = NO_INDEX; | |
const bool end_inside = moveInside(boundary_inside_optimal, end_inside, inside_loc_to_line_optimal.get(), end_point, end_inside_poly); |
comb_paths.back(), | ||
-offset_dist_to_get_from_on_the_polygon_to_outside, | ||
max_comb_distance_ignored, | ||
fail_on_unavoidable_obstacles); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter _end_inside
fail_on_unavoidable_obstacles); | |
const bool end_inside_min = moveInside(boundary_inside_minimum, end_inside, inside_loc_to_line_minimum.get(), end_point, end_inside_poly_min); |
combing_succeeded = LinePolygonsCrossings::comb( | ||
end_crossing.dest_part, | ||
*inside_loc_to_line_minimum, | ||
end_crossing.in_or_mid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
method moveInside
can be made const
end_crossing.in_or_mid, | |
bool Comb::moveInside(Polygons& boundary_inside, bool is_inside, LocToLineGrid* inside_loc_to_line, Point& dest_point, unsigned int& inside_poly) const |
comb_paths.back(), | ||
-offset_dist_to_get_from_on_the_polygon_to_outside, | ||
max_comb_distance_ignored, | ||
fail_on_unavoidable_obstacles); | ||
} | ||
// If the endpoint of the travel path changes with combing, then it means that we are moving to an outer wall | ||
// and we should unretract before the last travel move when traveling to that outer wall | ||
unretract_before_last_travel_move = combing_succeeded && end_point != travel_end_point_before_combing; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not use else
after return
unretract_before_last_travel_move = combing_succeeded && end_point != travel_end_point_before_combing; | |
} | ||
// If the endpoint of the travel path changes with combing, then it means that we are moving to an outer wall | ||
// and we should unretract before the last travel move when traveling to that outer wall | ||
unretract_before_last_travel_move = combing_succeeded && end_point != travel_end_point_before_combing; | ||
if (!combing_succeeded) | ||
{ // Couldn't comb between end point and computed crossing to the end part! Happens for very thin parts when the offset_to_get_off_boundary moves points to outside the polygon | ||
if (! combing_succeeded) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not use else
after return
if (! combing_succeeded) | |
inside_poly = cpp.poly_idx; | |
return true; | |
@@ -318,7 +383,7 @@ void Comb::moveCombPathInside(Polygons& boundary_inside, Polygons& boundary_insi | |||
return; | |||
} | |||
comb_path_output.push_back(comb_path_input[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter partsView_inside
comb_path_output.push_back(comb_path_input[0]); | |
for (unsigned int poly_idx : parts_view_inside[dest_part_idx]) |
@@ -336,28 +401,35 @@ void Comb::moveCombPathInside(Polygons& boundary_inside, Polygons& boundary_insi | |||
{ | |||
comb_path_output.push_back(comb_path_input[comb_path_input.size() - 1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
narrowing conversion from unsigned int
to signed type int
is implementation-defined
@@ -336,28 +401,35 @@ void Comb::moveCombPathInside(Polygons& boundary_inside, Polygons& boundary_insi | |||
{ | |||
comb_path_output.push_back(comb_path_input[comb_path_input.size() - 1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
narrowing conversion from unsigned int
to signed type int
is implementation-defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy
found issue(s) with the introduced code (10/10)
[_dest_point](Point candidate) | ||
{ | ||
return vSize2((candidate - _dest_point) / 10); | ||
}); | ||
dest_part = partsView_inside.assemblePart(dest_part_idx); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
narrowing conversion from cura::coord_t
(aka long long
) to signed type int
is implementation-defined
[_dest_point](Point candidate) | ||
{ | ||
return vSize2((candidate - _dest_point) / 10); | ||
}); | ||
dest_part = partsView_inside.assemblePart(dest_part_idx); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static member accessed through instance
in_or_mid = PolygonUtils::moveInside(best->first, cura::Comb::offset_dist_to_get_from_on_the_polygon_to_outside); |
[_dest_point](Point candidate) | ||
{ | ||
return vSize2((candidate - _dest_point) / 10); | ||
}); | ||
dest_part = partsView_inside.assemblePart(dest_part_idx); | ||
|
||
ClosestPolygonPoint boundary_crossing_point; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
narrowing conversion from cura::coord_t
(aka long long
) to signed type int
is implementation-defined
[_dest_point](Point candidate) | ||
{ | ||
return vSize2((candidate - _dest_point) / 10); | ||
}); | ||
dest_part = partsView_inside.assemblePart(dest_part_idx); | ||
|
||
ClosestPolygonPoint boundary_crossing_point; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static member accessed through instance
ClosestPolygonPoint boundary_crossing_point; | |
out = PolygonUtils::moveOutside(best->second, cura::Comb::offset_dist_to_get_from_on_the_polygon_to_outside); |
= [close_to, _dest_point, &boundary_crossing_point, &dist2_score, &dest_part_poly_indices](const PolygonsPointIndex& boundary_segment) | ||
{ | ||
if (dest_part_poly_indices.find(boundary_segment.poly_idx) == dest_part_poly_indices.end()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the parameter from
is copied for each invocation but only used as a const reference; consider making it a const reference
if (dest_part_poly_indices.find(boundary_segment.poly_idx) == dest_part_poly_indices.end()) | |
std::shared_ptr<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>> Comb::Crossing::findBestCrossing(const ExtruderTrain& train, const Polygons& outside, const ConstPolygonRef from, const Point estimated_start, const Point estimated_end, Comb& comber) |
= [close_to, _dest_point, &boundary_crossing_point, &dist2_score, &dest_part_poly_indices](const PolygonsPointIndex& boundary_segment) | ||
{ | ||
if (dest_part_poly_indices.find(boundary_segment.poly_idx) == dest_part_poly_indices.end()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the parameter from
is copied for each invocation but only used as a const reference; consider making it a const reference
if (dest_part_poly_indices.find(boundary_segment.poly_idx) == dest_part_poly_indices.end()) | |
std::shared_ptr<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>> Comb::Crossing::findBestCrossing(const ExtruderTrain& train, const Polygons& outside, ConstPolygonRef& from, const Point estimated_start, const Point estimated_end, Comb& comber) |
return true; // a.k.a. continue; | ||
} | ||
Point closest_here = LinearAlg2D::getClosestOnLineSegment(close_to, boundary_segment.p(), boundary_segment.next().p()); | ||
coord_t dist2_score_here = vSize2(close_to - closest_here) + vSize2(_dest_point - closest_here) / 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable best_crossing_dist2
is not initialized
coord_t dist2_score_here = vSize2(close_to - closest_here) + vSize2(_dest_point - closest_here) / 10; | |
coord_t best_crossing_dist2 = 0; |
@@ -435,7 +518,11 @@ bool Comb::Crossing::findOutside(const ExtruderTrain& train, const Polygons& out | |||
if (dest_is_inside || outside.inside(in_or_mid, true)) // start in_between |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid repeating the return type from the declaration; use a braced initializer list instead
if (dest_is_inside || outside.inside(in_or_mid, true)) // start in_between | |
return {); |
@@ -435,7 +518,11 @@ bool Comb::Crossing::findOutside(const ExtruderTrain& train, const Polygons& out | |||
if (dest_is_inside || outside.inside(in_or_mid, true)) // start in_between |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid repeating the return type from the declaration; use a braced initializer list instead
if (dest_is_inside || outside.inside(in_or_mid, true)) // start in_between | |
return std::shared_ptr<std::pair<ClosestPolygonPoint, ClosestPolygonPoint>>(}; |
# Conflicts: # src/SkirtBrim.cpp
Description
Type of change
How Has This Been Tested?
Test Configuration:
Checklist: