Simple brim ears impl (#1779)

* First working brim ear impl, ported from SuperSlicer

* Make brim ears configurable

* Generate ears only if ear size > 0

* Fix `Polygon::convex_points` as well as brim ear max angle

* Fix another error in `Polygon::convex_points` and `Polygon::concave_points`

* Apply brim ears to inner brims as well

* tweak hide and disable condition a bit

---------

Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
Noisyfox 2023-08-13 22:29:45 +08:00 committed by GitHub
parent afe1030b58
commit f714e72faa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 136 additions and 18 deletions

View file

@ -237,7 +237,7 @@ Points filter_points_by_vectors(const Points &poly, FilterFn filter)
// p2 is next point to the currently visited point p1.
Vec2d v2 = (p2 - p1).cast<double>();
if (filter(v1, v2))
out.emplace_back(p2);
out.emplace_back(p1);
v1 = v2;
p1 = p2;
}
@ -249,7 +249,7 @@ template<typename ConvexConcaveFilterFn>
Points filter_convex_concave_points_by_angle_threshold(const Points &poly, double angle_threshold, ConvexConcaveFilterFn convex_concave_filter)
{
assert(angle_threshold >= 0.);
if (angle_threshold < EPSILON) {
if (angle_threshold > EPSILON) {
double cos_angle = cos(angle_threshold);
return filter_points_by_vectors(poly, [convex_concave_filter, cos_angle](const Vec2d &v1, const Vec2d &v2){
return convex_concave_filter(v1, v2) && v1.normalized().dot(v2.normalized()) < cos_angle;