Skip to content

Commit

Permalink
Align circle and line approximation
Browse files Browse the repository at this point in the history
With this commit, all curve approximations work the same now, making
edge approximation much simpler.
  • Loading branch information
hannobraun committed Aug 29, 2022
1 parent be49a75 commit 972c635
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/algorithms/approx/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Approx for GlobalCurve {
) -> Self::Approximation {
match self.kind() {
CurveKind::Circle(curve) => approx_circle(curve, range, tolerance),
CurveKind::Line(_) => Vec::new(),
CurveKind::Line(_) => vec![range.start()],
}
}
}
Expand Down
22 changes: 1 addition & 21 deletions crates/fj-kernel/src/algorithms/approx/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,6 @@ impl Approx for Edge {
}
};

let mut points = self.curve().approx(tolerance, range);

// Insert the exact vertices of this edge into the approximation. This
// means we don't rely on the curve approximation to deliver accurate
// representations of these vertices, which they might not be able to
// do.
//
// If we used inaccurate representations of those vertices here, then
// that would lead to bugs in the approximation, as points that should
// refer to the same vertex would be understood to refer to very close,
// but distinct vertices.
let vertices = self
.vertices()
.convert(|vertex| (vertex.position(), vertex.global().position()));
if let Some([(point_curve, point_global), _]) = vertices {
let point_surface =
self.curve().kind().point_from_curve_coords(point_curve);
points.insert(0, (point_surface, point_global));
}

points
self.curve().approx(tolerance, range)
}
}

0 comments on commit 972c635

Please sign in to comment.