From bc5d9b49616d07c9ea948d893ef845f2d2710356 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 20 May 2022 15:33:48 +0200 Subject: [PATCH 1/2] Fix inconsequential bug in sweep The curve there was wrong, but it didn't make a difference in practice. The bug could only have shown up during approximation, and since this code only constructs line segments, the wrong curves were never used for approximation. --- crates/fj-kernel/src/algorithms/sweep.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep.rs b/crates/fj-kernel/src/algorithms/sweep.rs index 3dad26b5d..10407d037 100644 --- a/crates/fj-kernel/src/algorithms/sweep.rs +++ b/crates/fj-kernel/src/algorithms/sweep.rs @@ -1,9 +1,9 @@ use std::collections::HashMap; -use fj_math::{Transform, Triangle, Vector}; +use fj_math::{Line, Transform, Triangle, Vector}; use crate::{ - geometry::{Surface, SweptCurve}, + geometry::{Curve, Surface, SweptCurve}, shape::{Shape, ValidationError}, topology::{Cycle, Edge, Face}, }; @@ -94,16 +94,18 @@ pub fn sweep_shape( vertex_bottom_to_edge .entry(vertex_bottom.clone()) .or_insert_with(|| { - let curve = target - .insert(edge_source.get().curve()) - .unwrap(); - let vertex_top = source_to_top .vertices() .get(&vertex_source.canonical()) .unwrap() .clone(); + let curve = Curve::Line(Line::from_points([ + vertex_bottom.get().point(), + vertex_top.get().point(), + ])); + let curve = target.insert(curve).unwrap(); + target .merge(Edge::new( curve, From 7c26846eedee7a832b5e082c0ba81b9fca709705 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 20 May 2022 15:47:39 +0200 Subject: [PATCH 2/2] Simplify code --- crates/fj-kernel/src/algorithms/sweep.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep.rs b/crates/fj-kernel/src/algorithms/sweep.rs index 10407d037..c651bbd66 100644 --- a/crates/fj-kernel/src/algorithms/sweep.rs +++ b/crates/fj-kernel/src/algorithms/sweep.rs @@ -1,9 +1,9 @@ use std::collections::HashMap; -use fj_math::{Line, Transform, Triangle, Vector}; +use fj_math::{Transform, Triangle, Vector}; use crate::{ - geometry::{Curve, Surface, SweptCurve}, + geometry::{Surface, SweptCurve}, shape::{Shape, ValidationError}, topology::{Cycle, Edge, Face}, }; @@ -100,17 +100,11 @@ pub fn sweep_shape( .unwrap() .clone(); - let curve = Curve::Line(Line::from_points([ - vertex_bottom.get().point(), - vertex_top.get().point(), - ])); - let curve = target.insert(curve).unwrap(); - - target - .merge(Edge::new( - curve, - Some([vertex_bottom, vertex_top]), - )) + let points = [vertex_bottom, vertex_top] + .map(|vertex| vertex.get().point()); + + Edge::builder(&mut target) + .build_line_segment_from_points(points) .unwrap() }) .clone()