From 2e78643d26833b1a9cd41d724e192fa3dd7a30b0 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 21 Apr 2023 11:24:16 +0200 Subject: [PATCH 1/3] Convert `Triangle` into `Polygon` --- crates/fj-kernel/src/operations/build/face.rs | 10 +++++----- crates/fj-kernel/src/operations/build/mod.rs | 2 +- crates/fj-kernel/src/operations/build/shell.rs | 10 +++++----- crates/fj-kernel/src/operations/mod.rs | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/fj-kernel/src/operations/build/face.rs b/crates/fj-kernel/src/operations/build/face.rs index 127777444..8f6cabe55 100644 --- a/crates/fj-kernel/src/operations/build/face.rs +++ b/crates/fj-kernel/src/operations/build/face.rs @@ -16,7 +16,7 @@ pub trait BuildFace { fn triangle( points: [impl Into>; 3], objects: &mut Service, - ) -> Triangle { + ) -> Polygon<3> { let [a, b, c] = points.map(Into::into); let surface = Surface::plane_from_points([a, b, c]).insert(objects); @@ -39,7 +39,7 @@ pub trait BuildFace { let face = Face::new(surface, exterior, [], None); - Triangle { + Polygon { face, edges, vertices, @@ -52,13 +52,13 @@ impl BuildFace for Face {} /// A triangle /// /// Returned by [`BuildFace::triangle`]. -pub struct Triangle { +pub struct Polygon { /// The face that forms the triangle pub face: Face, /// The edges of the triangle - pub edges: [Handle; 3], + pub edges: [Handle; D], /// The vertices of the triangle - pub vertices: [Handle; 3], + pub vertices: [Handle; D], } diff --git a/crates/fj-kernel/src/operations/build/mod.rs b/crates/fj-kernel/src/operations/build/mod.rs index 2cc47ed35..7f2e1a85a 100644 --- a/crates/fj-kernel/src/operations/build/mod.rs +++ b/crates/fj-kernel/src/operations/build/mod.rs @@ -7,7 +7,7 @@ mod surface; pub use self::{ cycle::BuildCycle, edge::BuildHalfEdge, - face::{BuildFace, Triangle}, + face::{BuildFace, Polygon}, shell::{BuildShell, Tetrahedron}, surface::BuildSurface, }; diff --git a/crates/fj-kernel/src/operations/build/shell.rs b/crates/fj-kernel/src/operations/build/shell.rs index a8f0f3376..a61298f0d 100644 --- a/crates/fj-kernel/src/operations/build/shell.rs +++ b/crates/fj-kernel/src/operations/build/shell.rs @@ -7,7 +7,7 @@ use crate::{ storage::Handle, }; -use super::{BuildFace, Triangle}; +use super::{BuildFace, Polygon}; /// Build a [`Shell`] pub trait BuildShell { @@ -35,19 +35,19 @@ pub trait BuildShell { ) -> Tetrahedron { let [a, b, c, d] = points.map(Into::into); - let [Triangle { + let [Polygon { face: face_abc, edges: [ab, bc, ca], vertices: [a, b, c], - }, Triangle { + }, Polygon { face: face_bad, edges: [ba, ad, db], vertices: [_, _, d], - }, Triangle { + }, Polygon { face: face_dac, edges: [da, ac, cd], .. - }, Triangle { + }, Polygon { face: face_cbd, edges: [cb, bd, dc], .. diff --git a/crates/fj-kernel/src/operations/mod.rs b/crates/fj-kernel/src/operations/mod.rs index 7b05c5335..4d9185e0f 100644 --- a/crates/fj-kernel/src/operations/mod.rs +++ b/crates/fj-kernel/src/operations/mod.rs @@ -7,7 +7,7 @@ mod update; pub use self::{ build::{ BuildCycle, BuildFace, BuildHalfEdge, BuildShell, BuildSurface, - Tetrahedron, Triangle, + Polygon, Tetrahedron, }, insert::Insert, update::{UpdateCycle, UpdateFace, UpdateHalfEdge, UpdateShell}, From d906a0d486ebc51b14a0ca70420276f1d3a369b6 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 21 Apr 2023 11:25:12 +0200 Subject: [PATCH 2/3] Update documentation of `Polygon` --- crates/fj-kernel/src/operations/build/face.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/fj-kernel/src/operations/build/face.rs b/crates/fj-kernel/src/operations/build/face.rs index 8f6cabe55..5be614c85 100644 --- a/crates/fj-kernel/src/operations/build/face.rs +++ b/crates/fj-kernel/src/operations/build/face.rs @@ -49,16 +49,14 @@ pub trait BuildFace { impl BuildFace for Face {} -/// A triangle -/// -/// Returned by [`BuildFace::triangle`]. +/// A polygon pub struct Polygon { - /// The face that forms the triangle + /// The face that forms the polygon pub face: Face, - /// The edges of the triangle + /// The edges of the polygon pub edges: [Handle; D], - /// The vertices of the triangle + /// The vertices of the polygon pub vertices: [Handle; D], } From 8d389c882dae9b7713095a2bc77d002aa4a92c9a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 21 Apr 2023 11:26:51 +0200 Subject: [PATCH 3/3] Add implementation note --- crates/fj-kernel/src/operations/build/face.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/fj-kernel/src/operations/build/face.rs b/crates/fj-kernel/src/operations/build/face.rs index 5be614c85..d83536c88 100644 --- a/crates/fj-kernel/src/operations/build/face.rs +++ b/crates/fj-kernel/src/operations/build/face.rs @@ -50,6 +50,12 @@ pub trait BuildFace { impl BuildFace for Face {} /// A polygon +/// +/// # Implementation Note +/// +/// Currently code that deals with `Polygon` might assume that the polygon has +/// no holes. Unless you create a `Polygon` yourself, or modify a `Polygon`'s +/// `face` field to have interior cycles, this should not affect you. pub struct Polygon { /// The face that forms the polygon pub face: Face,