Skip to content

Commit

Permalink
Merge pull request #1038 from hannobraun/sweep
Browse files Browse the repository at this point in the history
Continue cleaning up edge sweeping algorithm
  • Loading branch information
hannobraun authored Sep 5, 2022
2 parents b223b8b + ffb2a97 commit 46ddf58
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions crates/fj-kernel/src/algorithms/sweep/edge.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use fj_interop::mesh::Color;
use fj_math::{Line, Point, Scalar, Transform, Triangle};
use fj_math::{Line, Scalar, Transform, Triangle};

use crate::{
algorithms::{
approx::{Approx, Tolerance},
reverse::Reverse,
transform::TransformObject,
},
objects::{
Curve, CurveKind, Cycle, Edge, Face, GlobalCurve, GlobalEdge, Surface,
Vertex, VerticesOfEdge,
Curve, CurveKind, Cycle, Edge, Face, GlobalEdge, Surface, Vertex,
VerticesOfEdge,
},
};

Expand Down Expand Up @@ -57,6 +58,9 @@ fn create_non_continuous_side_face(
let vertices = edge.vertices().get_or_panic();

let curve = {
// Please note that creating a line here is correct, even if the
// global curve is a circle. Projected into the side surface, it is
// going to be a line either way.
let points = vertices.map(|vertex| {
(vertex.position(), [vertex.position().t, Scalar::ZERO])
});
Expand All @@ -83,36 +87,25 @@ fn create_non_continuous_side_face(

let top_edge = {
let bottom_vertices = bottom_edge.vertices().get_or_panic();
let points_surface = bottom_vertices
.map(|vertex| Point::from([vertex.position().t, Scalar::ONE]));

let global_vertices = side_edges.map(|edge| {
let [_, vertex] = edge.vertices().get_or_panic();
*vertex.global()
});

let curve = {
let [a_curve, b_curve] =
bottom_vertices.map(|vertex| vertex.position());
let [a_surface, b_surface] = points_surface;
let [a_global, b_global] =
global_vertices.map(|vertex| vertex.position());

let global = {
let line = Line::from_points_with_line_coords([
(a_curve, a_global),
(b_curve, b_global),
]);

GlobalCurve::from_kind(CurveKind::Line(line))
};

let line = Line::from_points_with_line_coords([
(a_curve, a_surface),
(b_curve, b_surface),
]);

Curve::new(surface, CurveKind::Line(line), global)
let global = bottom_edge.curve().global().translate(path.inner());

// Please note that creating a line here is correct, even if the
// global curve is a circle. Projected into the side surface, it is
// going to be a line either way.
let points = bottom_vertices.map(|vertex| {
(vertex.position(), [vertex.position().t, Scalar::ONE])
});
let kind =
CurveKind::Line(Line::from_points_with_line_coords(points));

Curve::new(surface, kind, global)
};

let global = {
Expand Down

0 comments on commit 46ddf58

Please sign in to comment.