Skip to content

Commit

Permalink
Merge pull request #1054 from hannobraun/sweep
Browse files Browse the repository at this point in the history
Fix dodgy assumption in edge sweeping code
  • Loading branch information
hannobraun authored Sep 8, 2022
2 parents 72fc56f + 6d410f4 commit d09ab54
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
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

0 comments on commit d09ab54

Please sign in to comment.