Skip to content
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

Merged
merged 11 commits into from
Jul 24, 2023
36 changes: 23 additions & 13 deletions include/utils/actions/smooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
#ifndef UTILS_VIEWS_SMOOTH_H
#define UTILS_VIEWS_SMOOTH_H

#include <functional>
#include <numbers>
#include <set>
#include "utils/types/arachne.h"
#include "utils/types/generic.h"
#include "utils/types/geometry.h"
#include "utils/types/get.h"

#include <range/v3/action/remove_if.hpp>
#include <range/v3/functional/bind_back.hpp>
Expand All @@ -18,10 +19,9 @@
#include <range/v3/view/single.hpp>
#include <range/v3/view/take.hpp>

#include "utils/types/arachne.h"
#include "utils/types/generic.h"
#include "utils/types/geometry.h"
#include "utils/types/get.h"
#include <functional>
#include <numbers>
#include <set>

namespace cura::actions
{
Expand All @@ -34,11 +34,12 @@ struct smooth_fn
}

template<class Rng>
requires ranges::forward_range<Rng> && ranges::sized_range<Rng> && ranges::erasable_range<Rng, ranges::iterator_t<Rng>, ranges::sentinel_t<Rng>> && (utils::point2d<ranges::range_value_t<Rng>> || utils::junctions<Rng>)
constexpr auto operator()(Rng&& rng, const utils::integral auto max_resolution, const utils::floating_point auto fluid_angle) const
requires ranges::forward_range<Rng> && ranges::sized_range<Rng> && ranges::erasable_range<Rng, ranges::iterator_t<Rng>, ranges::sentinel_t<Rng>> &&(
utils::point2d<ranges::range_value_t<Rng>> || utils::junctions<Rng>)constexpr auto
operator()(Rng&& rng, const utils::integral auto max_resolution, const utils::floating_point auto fluid_angle) const
{
const auto size = ranges::distance(rng) - 1;
if (size < 3)
if (size < 4)
casperlamboo marked this conversation as resolved.
Show resolved Hide resolved
{
return static_cast<Rng&&>(rng);
}
Expand Down Expand Up @@ -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>
saumyaj3 marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter A

Suggested change
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,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter B

Suggested change
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,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter C

Suggested change
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,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter D

Suggested change
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,

requires utils::point2d<Point> || utils::junction<Point>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter AB_magnitude

Suggested change
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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter BC_magnitude

Suggested change
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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter CD_magnitude

Suggested change
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter BC_magnitude

Suggested change
Point* A,
if (bc_magnitude > max_resolution / 10) // TODO: make dedicated front-end setting for this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ cppcoreguidelines-avoid-magic-numbers ⚠️
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter A

Suggested change
const utils::floating_point auto fluid_angle,
const double cos_A = std::acos(cosAngle(a, B, C, AB_magnitude, BC_magnitude));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter B

Suggested change
const utils::floating_point auto fluid_angle,
const double cos_A = std::acos(cosAngle(A, b, C, AB_magnitude, BC_magnitude));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter C

Suggested change
const utils::floating_point auto fluid_angle,
const double cos_A = std::acos(cosAngle(A, B, c, AB_magnitude, BC_magnitude));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter AB_magnitude

Suggested change
const utils::floating_point auto fluid_angle,
const double cos_A = std::acos(cosAngle(A, B, C, ab_magnitude, BC_magnitude));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter BC_magnitude

Suggested change
const utils::floating_point auto fluid_angle,
const double cos_A = std::acos(cosAngle(A, B, C, AB_magnitude, bc_magnitude));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for variable cos_A

Suggested change
const utils::floating_point auto fluid_angle,
const double cos_a = std::acos(cosAngle(A, B, C, AB_magnitude, BC_magnitude));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ clang-diagnostic-error ⚠️
no member named acos in namespace std

const utils::integral auto max_resolution,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter A

Suggested change
const utils::integral auto max_resolution,
const double cos_B = std::acos(cosAngle(a, B, D, AB_magnitude, CD_magnitude));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter B

Suggested change
const utils::integral auto max_resolution,
const double cos_B = std::acos(cosAngle(A, b, D, AB_magnitude, CD_magnitude));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter D

Suggested change
const utils::integral auto max_resolution,
const double cos_B = std::acos(cosAngle(A, B, d, AB_magnitude, CD_magnitude));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter AB_magnitude

Suggested change
const utils::integral auto max_resolution,
const double cos_B = std::acos(cosAngle(A, B, D, ab_magnitude, CD_magnitude));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for parameter CD_magnitude

Suggested change
const utils::integral auto max_resolution,
const double cos_B = std::acos(cosAngle(A, B, D, AB_magnitude, cd_magnitude));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for variable cos_B

Suggested change
const utils::integral auto max_resolution,
const double cos_b = std::acos(cosAngle(A, B, D, AB_magnitude, CD_magnitude));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ clang-diagnostic-error ⚠️
no member named acos in namespace std

const utils::floating_point auto AB_magnitude,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for variable cos_A

Suggested change
const utils::floating_point auto AB_magnitude,
const auto abs_angle = std::abs(cos_a - cos_B);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for variable cos_B

Suggested change
const utils::floating_point auto AB_magnitude,
const auto abs_angle = std::abs(cos_A - cos_b);

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
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for class smooth_fn

Suggested change
{
inline constexpr SmoothFn smooth{};

Expand Down
Loading