From bedf2fd14e102854d9f959ce8cbbc62800a5a8fd Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 16 Dec 2022 16:55:42 +0100 Subject: [PATCH] Return coords from `SurfaceBuilder` method --- crates/fj-kernel/src/builder/shell.rs | 3 ++- crates/fj-kernel/src/builder/surface.rs | 27 ++++++++++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 75bc79f49..1e2006ba5 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -67,7 +67,8 @@ impl ShellBuilder for PartialShell { }); let c = a + [Z, Z, edge_length]; - let surface = PartialSurface::plane_from_points([a, b, c]); + let (surface, _) = + PartialSurface::plane_from_points([a, b, c]); Partial::from_partial(surface) }) .collect::>(); diff --git a/crates/fj-kernel/src/builder/surface.rs b/crates/fj-kernel/src/builder/surface.rs index dc0b8db40..54f1efcdd 100644 --- a/crates/fj-kernel/src/builder/surface.rs +++ b/crates/fj-kernel/src/builder/surface.rs @@ -1,4 +1,4 @@ -use fj_math::{Point, Vector}; +use fj_math::{Point, Scalar, Vector}; use crate::{ geometry::{path::GlobalPath, surface::SurfaceGeometry}, @@ -11,7 +11,9 @@ pub trait SurfaceBuilder: Sized { fn from_axes(u: GlobalPath, v: impl Into>) -> Self; /// Construct a plane from 3 points - fn plane_from_points(points: [impl Into>; 3]) -> Self; + fn plane_from_points( + points: [impl Into>; 3], + ) -> (Self, [Point<2>; 3]); } impl SurfaceBuilder for PartialSurface { @@ -23,14 +25,25 @@ impl SurfaceBuilder for PartialSurface { } } - fn plane_from_points(points: [impl Into>; 3]) -> Self { + fn plane_from_points( + points: [impl Into>; 3], + ) -> (Self, [Point<2>; 3]) { let [a, b, c] = points.map(Into::into); - let (u, _) = GlobalPath::line_from_points([a, b]); + let (u, u_coords) = GlobalPath::line_from_points([a, b]); let v = c - a; - Self { - geometry: Some(SurfaceGeometry { u, v }), - } + let coords = { + let [a, b] = u_coords.map(|point| point.t); + [[a, Scalar::ZERO], [b, Scalar::ZERO], [a, Scalar::ONE]] + .map(Point::from) + }; + + ( + Self { + geometry: Some(SurfaceGeometry { u, v }), + }, + coords, + ) } }