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

Continue cleaning up edge sweeping algorithm #1038

Merged
merged 8 commits into from
Sep 5, 2022
Merged
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
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