Eliminate warnings caused by changes to aid new libslic3r backend
This commit is contained in:
parent
ad19ab219d
commit
dca67822d1
5 changed files with 44 additions and 18 deletions
|
@ -10,10 +10,6 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
// Borrowed from C++20
|
||||
template<class T>
|
||||
using remove_cvref_t = std::remove_reference_t<std::remove_cv_t<T>>;
|
||||
|
||||
// Override for valid execution policies
|
||||
template<class EP> struct IsExecutionPolicy_ : public std::false_type {};
|
||||
|
||||
|
|
|
@ -595,7 +595,6 @@ static inline bool line_rounded_thick_segment_collision(
|
|||
// Very short line vector. Just test whether the center point is inside the offset line.
|
||||
Vec2d lpt = 0.5 * (line_a + line_b);
|
||||
if (segment_l > SCALED_EPSILON) {
|
||||
struct Linef { Vec2d a, b; };
|
||||
intersects = line_alg::distance_to_squared(Linef{ segment_a, segment_b }, lpt) < offset2;
|
||||
} else
|
||||
intersects = (0.5 * (segment_a + segment_b) - lpt).squaredNorm() < offset2;
|
||||
|
@ -1196,8 +1195,6 @@ static inline void mark_boundary_segments_overlapping_infill(
|
|||
// Spacing (width) of the infill lines.
|
||||
const double spacing)
|
||||
{
|
||||
struct Linef { Vec2d a; Vec2d b; };
|
||||
|
||||
for (ContourIntersectionPoint &cp : graph.map_infill_end_point_to_boundary) {
|
||||
const Points &contour = graph.boundary[cp.contour_idx];
|
||||
const std::vector<double> &contour_params = graph.boundary_params[cp.contour_idx];
|
||||
|
@ -2003,9 +2000,8 @@ static double evaluate_support_arch_cost(const Polyline &pl)
|
|||
|
||||
double dmax = 0;
|
||||
// Maximum distance in Y axis out of the (ymin, ymax) band and from the (front, back) line.
|
||||
struct Linef { Vec2d a, b; };
|
||||
Linef line { front.cast<double>(), back.cast<double>() };
|
||||
for (const Point pt : pl.points)
|
||||
for (const Point &pt : pl.points)
|
||||
dmax = std::max<double>(std::max(dmax, line_alg::distance_to(line, Vec2d(pt.cast<double>()))), std::max(pt.y() - ymax, ymin - pt.y()));
|
||||
return dmax;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include "libslic3r.h"
|
||||
#include "Point.hpp"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class BoundingBox;
|
||||
|
@ -20,12 +22,28 @@ Linef3 transform(const Linef3& line, const Transform3d& t);
|
|||
|
||||
namespace line_alg {
|
||||
|
||||
template<class L, class En = void> struct Traits {
|
||||
static constexpr int Dim = L::Dim;
|
||||
using Scalar = typename L::Scalar;
|
||||
|
||||
static Vec<Dim, Scalar>& get_a(L &l) { return l.a; }
|
||||
static Vec<Dim, Scalar>& get_b(L &l) { return l.b; }
|
||||
static const Vec<Dim, Scalar>& get_a(const L &l) { return l.a; }
|
||||
static const Vec<Dim, Scalar>& get_b(const L &l) { return l.b; }
|
||||
};
|
||||
|
||||
template<class L> const constexpr int Dim = Traits<remove_cvref_t<L>>::Dim;
|
||||
template<class L> using Scalar = typename Traits<remove_cvref_t<L>>::Scalar;
|
||||
|
||||
template<class L> auto get_a(L &&l) { return Traits<remove_cvref_t<L>>::get_a(l); }
|
||||
template<class L> auto get_b(L &&l) { return Traits<remove_cvref_t<L>>::get_b(l); }
|
||||
|
||||
// Distance to the closest point of line.
|
||||
template<class L, class T, int N>
|
||||
double distance_to_squared(const L &line, const Vec<N, T> &point)
|
||||
template<class L>
|
||||
double distance_to_squared(const L &line, const Vec<Dim<L>, Scalar<L>> &point)
|
||||
{
|
||||
const Vec<N, double> v = (line.b - line.a).template cast<double>();
|
||||
const Vec<N, double> va = (point - line.a).template cast<double>();
|
||||
const Vec<Dim<L>, double> v = (get_b(line) - get_a(line)).template cast<double>();
|
||||
const Vec<Dim<L>, double> va = (point - get_a(line)).template cast<double>();
|
||||
const double l2 = v.squaredNorm(); // avoid a sqrt
|
||||
if (l2 == 0.0)
|
||||
// a == b case
|
||||
|
@ -35,12 +53,12 @@ double distance_to_squared(const L &line, const Vec<N, T> &point)
|
|||
// It falls where t = [(this-a) . (b-a)] / |b-a|^2
|
||||
const double t = va.dot(v) / l2;
|
||||
if (t < 0.0) return va.squaredNorm(); // beyond the 'a' end of the segment
|
||||
else if (t > 1.0) return (point - line.b).template cast<double>().squaredNorm(); // beyond the 'b' end of the segment
|
||||
else if (t > 1.0) return (point - get_b(line)).template cast<double>().squaredNorm(); // beyond the 'b' end of the segment
|
||||
return (t * v - va).squaredNorm();
|
||||
}
|
||||
|
||||
template<class L, class T, int N>
|
||||
double distance_to(const L &line, const Vec<N, T> &point)
|
||||
template<class L>
|
||||
double distance_to(const L &line, const Vec<Dim<L>, Scalar<L>> &point)
|
||||
{
|
||||
return std::sqrt(distance_to_squared(line, point));
|
||||
}
|
||||
|
@ -84,6 +102,9 @@ public:
|
|||
|
||||
Point a;
|
||||
Point b;
|
||||
|
||||
static const constexpr int Dim = 2;
|
||||
using Scalar = Point::Scalar;
|
||||
};
|
||||
|
||||
class ThickLine : public Line
|
||||
|
@ -107,6 +128,9 @@ public:
|
|||
|
||||
Vec3crd a;
|
||||
Vec3crd b;
|
||||
|
||||
static const constexpr int Dim = 3;
|
||||
using Scalar = Vec3crd::Scalar;
|
||||
};
|
||||
|
||||
class Linef
|
||||
|
@ -117,6 +141,9 @@ public:
|
|||
|
||||
Vec2d a;
|
||||
Vec2d b;
|
||||
|
||||
static const constexpr int Dim = 2;
|
||||
using Scalar = Vec2d::Scalar;
|
||||
};
|
||||
|
||||
class Linef3
|
||||
|
@ -133,6 +160,9 @@ public:
|
|||
|
||||
Vec3d a;
|
||||
Vec3d b;
|
||||
|
||||
static const constexpr int Dim = 3;
|
||||
using Scalar = Vec3d::Scalar;
|
||||
};
|
||||
|
||||
BoundingBox get_extents(const Lines &lines);
|
||||
|
|
|
@ -106,8 +106,8 @@ template<class C> bool all_of(const C &container)
|
|||
});
|
||||
}
|
||||
|
||||
template<class T>
|
||||
using remove_cvref_t = std::remove_reference_t<std::remove_cv_t<T>>;
|
||||
//template<class T>
|
||||
//using remove_cvref_t = std::remove_reference_t<std::remove_cv_t<T>>;
|
||||
|
||||
/// Exactly like Matlab https://www.mathworks.com/help/matlab/ref/linspace.html
|
||||
template<class T, class I, class = IntegerOnly<I>>
|
||||
|
|
|
@ -308,6 +308,10 @@ IntegerOnly<I, std::vector<T, Args...>> reserve_vector(I capacity)
|
|||
return ret;
|
||||
}
|
||||
|
||||
// Borrowed from C++20
|
||||
template<class T>
|
||||
using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>;
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue