From 37c7cb597c8337a3219eaae07ccdb78916ba1378 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 22 Mar 2024 15:43:01 +0100 Subject: [PATCH] Refactor to simplify --- crates/fj-core/src/validate/shell.rs | 62 +++++++--------------------- 1 file changed, 16 insertions(+), 46 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index a8826ae42..2f5597857 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -413,7 +413,7 @@ fn distances( mod tests { use crate::{ assert_contains_err, - objects::{Curve, Shell}, + objects::{Curve, HalfEdge, Shell}, operations::{ build::BuildShell, geometry::UpdateHalfEdgeGeometry, @@ -445,51 +445,21 @@ mod tests { cycle.update_half_edge( cycle.half_edges().nth_circular(0), |half_edge, core| { - // This is going to be weird: - // - // - That first call to `update_path` is - // going to reverse a path and insert - // a new object with the reversed - // path. - // - The next call to `update_boundary` - // relies on that, because it inserts - // an object too, and that would cause - // a validation failure without the - // first call. - // - But the new object created from - // those two operations doesn't - // actually have its geometry set in - // the geometry layer, because that - // happens in `update_path`, for an - // earlier version of the object. - // - So we need a last `set_path`, which - // sets the path again. - // - // This is very weird, but good new is, - // it's just an artifact of the - // transition from a unified object - // graph to separate topology and - // geometry layers. This should clear up - // again, once the separation is - // finished, and all APIs can adapt to - // the new reality. - [half_edge - .update_path( - |path| path.reverse(), - core, - ) - .update_boundary( - |boundary| boundary.reverse(), - core, - ) - .set_path( - core.layers - .geometry - .of_half_edge(half_edge) - .path - .reverse(), - &mut core.layers.geometry, - )] + [HalfEdge::new( + half_edge.path().reverse(), + half_edge.boundary().reverse(), + half_edge.curve().clone(), + half_edge.start_vertex().clone(), + ) + .insert(core) + .set_path( + core.layers + .geometry + .of_half_edge(half_edge) + .path + .reverse(), + &mut core.layers.geometry, + )] }, core, )