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

Fix dodgy assumption in edge sweeping code #1054

Merged
merged 4 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crates/fj-kernel/src/algorithms/sweep/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ fn create_non_continuous_side_face(
let [_, prev_last] = edges[i].vertices().get_or_panic();
let [next_first, _] = edges[j].vertices().get_or_panic();

if prev_last.global_form() != next_first.global_form() {
// Need to compare surface forms here, as the global forms might be
// coincident when sweeping circles, despite the vertices being
// different!
if prev_last.surface_form() != next_first.surface_form() {
edges[j] = edges[j].reverse();
}

Expand Down
33 changes: 18 additions & 15 deletions crates/fj-kernel/src/builder/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,25 @@ impl EdgeBuilder {

/// Create a circle from the given radius
pub fn circle_from_radius(&self, radius: Scalar) -> Edge {
let curve_local = CurveKind::Circle(Circle::new(
Point::origin(),
Vector::from([radius, Scalar::ZERO]),
Vector::from([Scalar::ZERO, radius]),
));
let curve_global =
GlobalCurve::from_kind(CurveKind::Circle(Circle::new(
let curve = {
let local = CurveKind::Circle(Circle::new(
Point::origin(),
Vector::from([radius, Scalar::ZERO, Scalar::ZERO]),
Vector::from([Scalar::ZERO, radius, Scalar::ZERO]),
)));

Edge::from_curve_and_vertices(
Curve::new(self.surface, curve_local, curve_global),
VerticesOfEdge::none(),
)
Vector::from([radius, Scalar::ZERO]),
Vector::from([Scalar::ZERO, radius]),
));
let global =
GlobalCurve::from_kind(CurveKind::Circle(Circle::new(
Point::origin(),
Vector::from([radius, Scalar::ZERO, Scalar::ZERO]),
Vector::from([Scalar::ZERO, radius, Scalar::ZERO]),
)));

Curve::new(self.surface, local, global)
};

let vertices = VerticesOfEdge::none();

Edge::from_curve_and_vertices(curve, vertices)
}

/// Create a line segment from two points
Expand Down